From 55fbe52c8aaaf85ded0d5c78613ccf25b3b28710 Mon Sep 17 00:00:00 2001 From: cb-karthikp Date: Tue, 24 Feb 2026 13:03:46 +0530 Subject: [PATCH 1/6] update to use gson parser --- ...dditionalBillingLogiqRetrieveResponse.java | 4 +- .../com/chargebee/v4/models/addon/Addon.java | 168 +- .../addon/responses/AddonCopyResponse.java | 8 +- .../addon/responses/AddonCreateResponse.java | 8 +- .../addon/responses/AddonDeleteResponse.java | 8 +- .../addon/responses/AddonListResponse.java | 25 +- .../responses/AddonRetrieveResponse.java | 8 +- .../responses/AddonUnarchiveResponse.java | 8 +- .../addon/responses/AddonUpdateResponse.java | 8 +- .../chargebee/v4/models/address/Address.java | 37 +- .../responses/AddressRetrieveResponse.java | 8 +- .../responses/AddressUpdateResponse.java | 8 +- .../AdvanceInvoiceSchedule.java | 49 +- .../v4/models/attachedItem/AttachedItem.java | 37 +- .../responses/AttachedItemCreateResponse.java | 8 +- .../responses/AttachedItemDeleteResponse.java | 8 +- .../responses/AttachedItemListResponse.java | 25 +- .../AttachedItemRetrieveResponse.java | 8 +- .../responses/AttachedItemUpdateResponse.java | 8 +- .../v4/models/attribute/Attribute.java | 9 +- .../BillingConfiguration.java | 19 +- .../com/chargebee/v4/models/brand/Brand.java | 9 +- .../BrandConfigurationRetrieveResponse.java | 4 +- .../models/businessEntity/BusinessEntity.java | 19 +- ...BusinessEntityCreateTransfersResponse.java | 9 +- .../BusinessEntityGetTransfersResponse.java | 28 +- .../BusinessEntityTransfer.java | 21 +- .../BusinessProfileRetrieveResponse.java | 4 +- .../com/chargebee/v4/models/card/Card.java | 61 +- .../card/responses/CardRetrieveResponse.java | 8 +- .../CardSwitchGatewayForCustomerResponse.java | 14 +- .../CopyCardForCustomerResponse.java | 9 +- .../DeleteCardForCustomerResponse.java | 8 +- .../UpdateCardForCustomerResponse.java | 14 +- .../chargebee/v4/models/comment/Comment.java | 21 +- .../responses/CommentCreateResponse.java | 8 +- .../responses/CommentDeleteResponse.java | 8 +- .../responses/CommentListResponse.java | 25 +- .../responses/CommentRetrieveResponse.java | 8 +- .../models/configuration/Configuration.java | 11 +- .../responses/ConfigurationListResponse.java | 12 +- .../chargebee/v4/models/contact/Contact.java | 23 +- .../v4/models/contractTerm/ContractTerm.java | 29 +- .../chargebee/v4/models/coupon/Coupon.java | 183 +-- .../coupon/responses/CouponCopyResponse.java | 8 +- .../CouponCreateForItemsResponse.java | 8 +- .../responses/CouponCreateResponse.java | 8 +- .../responses/CouponDeleteResponse.java | 8 +- .../coupon/responses/CouponListResponse.java | 25 +- .../responses/CouponRetrieveResponse.java | 8 +- .../responses/CouponUnarchiveResponse.java | 8 +- .../CouponUpdateForItemsResponse.java | 8 +- .../responses/CouponUpdateResponse.java | 8 +- .../v4/models/couponCode/CouponCode.java | 15 +- .../responses/CouponCodeArchiveResponse.java | 8 +- .../responses/CouponCodeCreateResponse.java | 8 +- .../responses/CouponCodeListResponse.java | 25 +- .../responses/CouponCodeRetrieveResponse.java | 8 +- .../v4/models/couponSet/CouponSet.java | 23 +- .../CouponSetAddCouponCodesResponse.java | 8 +- .../responses/CouponSetCreateResponse.java | 8 +- .../responses/CouponSetDeleteResponse.java | 8 +- ...ponSetDeleteUnusedCouponCodesResponse.java | 8 +- .../responses/CouponSetListResponse.java | 25 +- .../responses/CouponSetRetrieveResponse.java | 8 +- .../responses/CouponSetUpdateResponse.java | 8 +- .../v4/models/creditNote/CreditNote.java | 501 +++--- .../responses/CreditNoteCreateResponse.java | 14 +- .../responses/CreditNoteDeleteResponse.java | 8 +- .../CreditNoteDownloadEinvoiceResponse.java | 11 +- .../responses/CreditNoteListResponse.java | 25 +- .../responses/CreditNotePdfResponse.java | 8 +- .../CreditNoteRecordRefundResponse.java | 14 +- .../responses/CreditNoteRefundResponse.java | 14 +- ...itNoteRemoveTaxWithheldRefundResponse.java | 8 +- .../CreditNoteResendEinvoiceResponse.java | 8 +- .../responses/CreditNoteRetrieveResponse.java | 8 +- .../CreditNoteSendEinvoiceResponse.java | 8 +- .../CreditNotesForCustomerResponse.java | 29 +- .../responses/ImportCreditNoteResponse.java | 8 +- .../responses/VoidCreditNoteResponse.java | 8 +- .../CreditNoteEstimate.java | 209 +-- .../responses/CsvTaxRuleCreateResponse.java | 3 + .../v4/models/currency/Currency.java | 17 +- .../CurrencyAddScheduleResponse.java | 10 +- .../responses/CurrencyCreateResponse.java | 8 +- .../responses/CurrencyListResponse.java | 25 +- .../CurrencyRemoveScheduleResponse.java | 10 +- .../responses/CurrencyRetrieveResponse.java | 8 +- .../responses/CurrencyUpdateResponse.java | 8 +- .../v4/models/customer/Customer.java | 416 +++-- .../ContactsForCustomerResponse.java | 27 +- .../responses/CustomerAddContactResponse.java | 14 +- ...CustomerAddPromotionalCreditsResponse.java | 8 +- .../CustomerAssignPaymentRoleResponse.java | 14 +- .../CustomerChangeBillingDateResponse.java | 8 +- .../CustomerClearPersonalDataResponse.java | 8 +- .../CustomerCollectPaymentResponse.java | 14 +- .../responses/CustomerCreateResponse.java | 14 +- ...tomerDeductPromotionalCreditsResponse.java | 8 +- .../CustomerDeleteContactResponse.java | 14 +- .../CustomerDeleteRelationshipResponse.java | 8 +- .../responses/CustomerDeleteResponse.java | 14 +- .../responses/CustomerHierarchyResponse.java | 11 +- .../CustomerListHierarchyDetailResponse.java | 27 +- .../responses/CustomerListResponse.java | 31 +- .../responses/CustomerMergeResponse.java | 8 +- .../responses/CustomerMoveResponse.java | 8 +- .../CustomerRecordExcessPaymentResponse.java | 14 +- .../CustomerRelationshipsResponse.java | 8 +- .../responses/CustomerRetrieveResponse.java | 14 +- ...CustomerSetPromotionalCreditsResponse.java | 8 +- .../CustomerUpdateBillingInfoResponse.java | 14 +- .../CustomerUpdateContactResponse.java | 14 +- ...stomerUpdateHierarchySettingsResponse.java | 8 +- .../CustomerUpdatePaymentMethodResponse.java | 14 +- .../responses/CustomerUpdateResponse.java | 14 +- .../CustomerEntitlement.java | 17 +- ...lementEntitlementsForCustomerResponse.java | 29 +- .../differentialPrice/DifferentialPrice.java | 75 +- .../DifferentialPriceCreateResponse.java | 8 +- .../DifferentialPriceDeleteResponse.java | 8 +- .../DifferentialPriceListResponse.java | 27 +- .../DifferentialPriceRetrieveResponse.java | 8 +- .../DifferentialPriceUpdateResponse.java | 8 +- .../v4/models/discount/Discount.java | 41 +- .../v4/models/download/Download.java | 11 +- .../v4/models/einvoice/Einvoice.java | 13 +- .../v4/models/entitlement/Entitlement.java | 19 +- .../responses/EntitlementCreateResponse.java | 6 +- .../responses/EntitlementListResponse.java | 25 +- .../EntitlementOverride.java | 29 +- ...lementOverrideForSubscriptionResponse.java | 6 +- ...lementOverrideForSubscriptionResponse.java | 30 +- .../v4/models/estimate/Estimate.java | 1345 +++++++++-------- .../AdvanceInvoiceEstimateResponse.java | 8 +- ...bscriptionForCustomerEstimateResponse.java | 8 +- ...reateSubscriptionItemEstimateResponse.java | 8 +- ...iptionItemForCustomerEstimateResponse.java | 8 +- ...ateCancelSubscriptionForItemsResponse.java | 8 +- .../EstimateCancelSubscriptionResponse.java | 8 +- .../EstimateChangeTermEndResponse.java | 8 +- ...EstimateCreateInvoiceForItemsResponse.java | 8 +- .../EstimateCreateInvoiceResponse.java | 8 +- .../EstimateCreateSubscriptionResponse.java | 8 +- ...imateGiftSubscriptionForItemsResponse.java | 8 +- .../EstimateGiftSubscriptionResponse.java | 8 +- .../EstimatePauseSubscriptionResponse.java | 8 +- .../EstimatePaymentSchedulesResponse.java | 8 +- .../EstimateResumeSubscriptionResponse.java | 8 +- ...ateUpdateSubscriptionForItemsResponse.java | 8 +- .../EstimateUpdateSubscriptionResponse.java | 8 +- .../RegenerateInvoiceEstimateResponse.java | 8 +- .../responses/RenewalEstimateResponse.java | 8 +- .../UpcomingInvoicesEstimateResponse.java | 8 +- .../models/event/AddUsagesReminderEvent.java | 47 +- .../v4/models/event/AddonCreatedEvent.java | 35 +- .../v4/models/event/AddonDeletedEvent.java | 35 +- .../v4/models/event/AddonUpdatedEvent.java | 35 +- .../event/AttachedItemCreatedEvent.java | 35 +- .../event/AttachedItemDeletedEvent.java | 35 +- .../event/AttachedItemUpdatedEvent.java | 35 +- .../event/AuthorizationSucceededEvent.java | 35 +- .../event/AuthorizationVoidedEvent.java | 35 +- .../event/BusinessEntityCreatedEvent.java | 35 +- .../event/BusinessEntityDeletedEvent.java | 35 +- .../event/BusinessEntityUpdatedEvent.java | 35 +- .../v4/models/event/CardAddedEvent.java | 41 +- .../v4/models/event/CardDeletedEvent.java | 41 +- .../v4/models/event/CardExpiredEvent.java | 41 +- .../models/event/CardExpiryReminderEvent.java | 41 +- .../v4/models/event/CardUpdatedEvent.java | 41 +- .../event/ContractTermCancelledEvent.java | 35 +- .../event/ContractTermCompletedEvent.java | 35 +- .../event/ContractTermCreatedEvent.java | 35 +- .../event/ContractTermRenewedEvent.java | 35 +- .../event/ContractTermTerminatedEvent.java | 35 +- .../models/event/CouponCodesAddedEvent.java | 41 +- .../models/event/CouponCodesDeletedEvent.java | 47 +- .../models/event/CouponCodesUpdatedEvent.java | 41 +- .../v4/models/event/CouponCreatedEvent.java | 35 +- .../v4/models/event/CouponDeletedEvent.java | 35 +- .../models/event/CouponSetCreatedEvent.java | 41 +- .../models/event/CouponSetDeletedEvent.java | 41 +- .../models/event/CouponSetUpdatedEvent.java | 41 +- .../v4/models/event/CouponUpdatedEvent.java | 35 +- .../models/event/CreditNoteCreatedEvent.java | 35 +- .../CreditNoteCreatedWithBackdatingEvent.java | 35 +- .../models/event/CreditNoteDeletedEvent.java | 35 +- .../models/event/CreditNoteUpdatedEvent.java | 35 +- .../CustomerBusinessEntityChangedEvent.java | 42 +- .../v4/models/event/CustomerChangedEvent.java | 41 +- .../v4/models/event/CustomerCreatedEvent.java | 41 +- .../v4/models/event/CustomerDeletedEvent.java | 46 +- .../CustomerEntitlementsUpdatedEvent.java | 35 +- .../v4/models/event/CustomerMovedInEvent.java | 41 +- .../models/event/CustomerMovedOutEvent.java | 41 +- .../event/DifferentialPriceCreatedEvent.java | 35 +- .../event/DifferentialPriceDeletedEvent.java | 35 +- .../event/DifferentialPriceUpdatedEvent.java | 35 +- .../v4/models/event/DunningUpdatedEvent.java | 35 +- .../EntitlementOverridesAutoRemovedEvent.java | 54 +- .../EntitlementOverridesRemovedEvent.java | 42 +- .../EntitlementOverridesUpdatedEvent.java | 42 +- .../com/chargebee/v4/models/event/Event.java | 41 +- .../models/event/FeatureActivatedEvent.java | 54 +- .../v4/models/event/FeatureArchivedEvent.java | 41 +- .../v4/models/event/FeatureCreatedEvent.java | 54 +- .../v4/models/event/FeatureDeletedEvent.java | 54 +- .../models/event/FeatureReactivatedEvent.java | 41 +- .../v4/models/event/FeatureUpdatedEvent.java | 41 +- .../v4/models/event/GiftCancelledEvent.java | 35 +- .../v4/models/event/GiftClaimedEvent.java | 35 +- .../v4/models/event/GiftExpiredEvent.java | 35 +- .../v4/models/event/GiftScheduledEvent.java | 35 +- .../v4/models/event/GiftUnclaimedEvent.java | 35 +- .../v4/models/event/GiftUpdatedEvent.java | 35 +- .../models/event/HierarchyCreatedEvent.java | 35 +- .../models/event/HierarchyDeletedEvent.java | 35 +- .../v4/models/event/InvoiceDeletedEvent.java | 35 +- .../models/event/InvoiceGeneratedEvent.java | 35 +- .../InvoiceGeneratedWithBackdatingEvent.java | 35 +- .../v4/models/event/InvoiceUpdatedEvent.java | 35 +- .../v4/models/event/ItemCreatedEvent.java | 35 +- .../v4/models/event/ItemDeletedEvent.java | 35 +- .../event/ItemEntitlementsRemovedEvent.java | 54 +- .../event/ItemEntitlementsUpdatedEvent.java | 54 +- .../models/event/ItemFamilyCreatedEvent.java | 35 +- .../models/event/ItemFamilyDeletedEvent.java | 35 +- .../models/event/ItemFamilyUpdatedEvent.java | 35 +- .../models/event/ItemPriceCreatedEvent.java | 35 +- .../models/event/ItemPriceDeletedEvent.java | 35 +- .../ItemPriceEntitlementsRemovedEvent.java | 54 +- .../ItemPriceEntitlementsUpdatedEvent.java | 54 +- .../models/event/ItemPriceUpdatedEvent.java | 35 +- .../v4/models/event/ItemUpdatedEvent.java | 35 +- .../v4/models/event/MrrUpdatedEvent.java | 35 +- .../event/NetdPaymentDueReminderEvent.java | 35 +- .../OmnichannelOneTimeOrderCreatedEvent.java | 57 +- ...channelOneTimeOrderItemCancelledEvent.java | 57 +- .../OmnichannelSubscriptionCreatedEvent.java | 65 +- .../OmnichannelSubscriptionImportedEvent.java | 65 +- ...riptionItemCancellationScheduledEvent.java | 50 +- ...channelSubscriptionItemCancelledEvent.java | 50 +- ...lSubscriptionItemChangeScheduledEvent.java | 51 +- ...nichannelSubscriptionItemChangedEvent.java | 65 +- ...bscriptionItemDowngradeScheduledEvent.java | 50 +- ...hannelSubscriptionItemDowngradedEvent.java | 57 +- ...elSubscriptionItemDunningExpiredEvent.java | 50 +- ...elSubscriptionItemDunningStartedEvent.java | 50 +- ...nichannelSubscriptionItemExpiredEvent.java | 50 +- ...bscriptionItemGracePeriodExpiredEvent.java | 50 +- ...bscriptionItemGracePeriodStartedEvent.java | 50 +- ...elSubscriptionItemPauseScheduledEvent.java | 51 +- ...mnichannelSubscriptionItemPausedEvent.java | 50 +- ...annelSubscriptionItemReactivatedEvent.java | 50 +- ...nichannelSubscriptionItemRenewedEvent.java | 65 +- ...nnelSubscriptionItemResubscribedEvent.java | 65 +- ...nichannelSubscriptionItemResumedEvent.java | 50 +- ...ItemScheduledCancellationRemovedEvent.java | 51 +- ...iptionItemScheduledChangeRemovedEvent.java | 52 +- ...ionItemScheduledDowngradeRemovedEvent.java | 51 +- ...ichannelSubscriptionItemUpgradedEvent.java | 65 +- .../OmnichannelSubscriptionMovedInEvent.java | 42 +- .../OmnichannelTransactionCreatedEvent.java | 36 +- .../v4/models/event/OrderCancelledEvent.java | 35 +- .../v4/models/event/OrderCreatedEvent.java | 35 +- .../v4/models/event/OrderDeletedEvent.java | 35 +- .../v4/models/event/OrderDeliveredEvent.java | 35 +- .../event/OrderReadyToProcessEvent.java | 35 +- .../models/event/OrderReadyToShipEvent.java | 35 +- .../v4/models/event/OrderResentEvent.java | 35 +- .../v4/models/event/OrderReturnedEvent.java | 35 +- .../v4/models/event/OrderUpdatedEvent.java | 35 +- .../models/event/PaymentDueReminderEvent.java | 41 +- .../v4/models/event/PaymentFailedEvent.java | 59 +- .../models/event/PaymentInitiatedEvent.java | 59 +- .../event/PaymentIntentCreatedEvent.java | 35 +- .../event/PaymentIntentUpdatedEvent.java | 35 +- .../v4/models/event/PaymentRefundedEvent.java | 65 +- .../PaymentScheduleSchemeCreatedEvent.java | 38 +- .../PaymentScheduleSchemeDeletedEvent.java | 38 +- .../event/PaymentSchedulesCreatedEvent.java | 35 +- .../event/PaymentSchedulesUpdatedEvent.java | 35 +- .../models/event/PaymentSourceAddedEvent.java | 41 +- .../event/PaymentSourceDeletedEvent.java | 41 +- .../event/PaymentSourceExpiredEvent.java | 41 +- .../event/PaymentSourceExpiringEvent.java | 41 +- .../PaymentSourceLocallyDeletedEvent.java | 41 +- .../event/PaymentSourceUpdatedEvent.java | 41 +- .../models/event/PaymentSucceededEvent.java | 59 +- .../event/PendingInvoiceCreatedEvent.java | 35 +- .../event/PendingInvoiceUpdatedEvent.java | 35 +- .../v4/models/event/PlanCreatedEvent.java | 35 +- .../v4/models/event/PlanDeletedEvent.java | 35 +- .../v4/models/event/PlanUpdatedEvent.java | 35 +- .../event/PriceVariantCreatedEvent.java | 41 +- .../event/PriceVariantDeletedEvent.java | 41 +- .../event/PriceVariantUpdatedEvent.java | 41 +- .../v4/models/event/ProductCreatedEvent.java | 35 +- .../v4/models/event/ProductDeletedEvent.java | 35 +- .../v4/models/event/ProductUpdatedEvent.java | 35 +- .../event/PromotionalCreditsAddedEvent.java | 41 +- .../PromotionalCreditsDeductedEvent.java | 41 +- .../v4/models/event/PurchaseCreatedEvent.java | 35 +- .../v4/models/event/QuoteCreatedEvent.java | 35 +- .../v4/models/event/QuoteDeletedEvent.java | 35 +- .../v4/models/event/QuoteUpdatedEvent.java | 35 +- .../event/RecordPurchaseFailedEvent.java | 41 +- .../v4/models/event/RefundInitiatedEvent.java | 65 +- .../v4/models/event/RuleCreatedEvent.java | 35 +- .../v4/models/event/RuleDeletedEvent.java | 35 +- .../v4/models/event/RuleUpdatedEvent.java | 35 +- .../models/event/SalesOrderCreatedEvent.java | 35 +- .../models/event/SalesOrderUpdatedEvent.java | 35 +- .../event/SubscriptionActivatedEvent.java | 53 +- ...scriptionActivatedWithBackdatingEvent.java | 58 +- ...ptionAdvanceInvoiceScheduleAddedEvent.java | 47 +- ...ionAdvanceInvoiceScheduleRemovedEvent.java | 47 +- ...ionAdvanceInvoiceScheduleUpdatedEvent.java | 47 +- ...ubscriptionBusinessEntityChangedEvent.java | 42 +- ...bscriptionCanceledWithBackdatingEvent.java | 62 +- ...SubscriptionCancellationReminderEvent.java | 54 +- ...ubscriptionCancellationScheduledEvent.java | 54 +- .../event/SubscriptionCancelledEvent.java | 62 +- .../event/SubscriptionChangedEvent.java | 62 +- ...ubscriptionChangedWithBackdatingEvent.java | 62 +- .../SubscriptionChangesScheduledEvent.java | 54 +- .../event/SubscriptionCreatedEvent.java | 58 +- ...ubscriptionCreatedWithBackdatingEvent.java | 58 +- .../event/SubscriptionDeletedEvent.java | 54 +- .../SubscriptionEntitlementsCreatedEvent.java | 37 +- .../SubscriptionEntitlementsUpdatedEvent.java | 37 +- .../event/SubscriptionItemsRenewedEvent.java | 62 +- .../event/SubscriptionMovedInEvent.java | 35 +- .../event/SubscriptionMovedOutEvent.java | 35 +- .../SubscriptionMovementFailedEvent.java | 35 +- .../SubscriptionPauseScheduledEvent.java | 54 +- .../models/event/SubscriptionPausedEvent.java | 62 +- .../event/SubscriptionRampAppliedEvent.java | 35 +- .../event/SubscriptionRampCreatedEvent.java | 35 +- .../event/SubscriptionRampDeletedEvent.java | 35 +- .../event/SubscriptionRampDraftedEvent.java | 35 +- .../event/SubscriptionRampUpdatedEvent.java | 35 +- .../event/SubscriptionReactivatedEvent.java | 58 +- ...riptionReactivatedWithBackdatingEvent.java | 58 +- .../SubscriptionRenewalReminderEvent.java | 54 +- .../event/SubscriptionRenewedEvent.java | 58 +- .../event/SubscriptionResumedEvent.java | 58 +- .../SubscriptionResumptionScheduledEvent.java | 54 +- ...tionScheduledCancellationRemovedEvent.java | 54 +- ...scriptionScheduledChangesRemovedEvent.java | 54 +- ...ubscriptionScheduledPauseRemovedEvent.java | 54 +- ...iptionScheduledResumptionRemovedEvent.java | 54 +- ...bscriptionShippingAddressUpdatedEvent.java | 54 +- .../event/SubscriptionStartedEvent.java | 53 +- .../SubscriptionTrialEndReminderEvent.java | 54 +- .../event/SubscriptionTrialExtendedEvent.java | 54 +- .../models/event/TaxWithheldDeletedEvent.java | 47 +- .../event/TaxWithheldRecordedEvent.java | 47 +- .../event/TaxWithheldRefundedEvent.java | 47 +- .../v4/models/event/TokenConsumedEvent.java | 35 +- .../v4/models/event/TokenCreatedEvent.java | 35 +- .../v4/models/event/TokenExpiredEvent.java | 35 +- .../models/event/TransactionCreatedEvent.java | 35 +- .../models/event/TransactionDeletedEvent.java | 35 +- .../models/event/TransactionUpdatedEvent.java | 35 +- .../event/UnbilledChargesCreatedEvent.java | 34 +- .../event/UnbilledChargesDeletedEvent.java | 34 +- .../event/UnbilledChargesInvoicedEvent.java | 40 +- .../event/UnbilledChargesVoidedEvent.java | 34 +- .../models/event/UsageFileIngestedEvent.java | 35 +- .../v4/models/event/VariantCreatedEvent.java | 35 +- .../v4/models/event/VariantDeletedEvent.java | 35 +- .../v4/models/event/VariantUpdatedEvent.java | 35 +- .../event/VirtualBankAccountAddedEvent.java | 41 +- .../event/VirtualBankAccountDeletedEvent.java | 41 +- .../event/VirtualBankAccountUpdatedEvent.java | 41 +- .../event/VoucherCreateFailedEvent.java | 35 +- .../v4/models/event/VoucherCreatedEvent.java | 35 +- .../v4/models/event/VoucherExpiredEvent.java | 35 +- .../event/responses/EventListResponse.java | 25 +- .../responses/EventRetrieveResponse.java | 8 +- .../chargebee/v4/models/export/Export.java | 31 +- .../responses/ExportAddonsResponse.java | 8 +- .../ExportAttachedItemsResponse.java | 8 +- .../responses/ExportCouponsResponse.java | 8 +- .../responses/ExportCreditNotesResponse.java | 8 +- .../responses/ExportCustomersResponse.java | 8 +- .../ExportDeferredRevenueResponse.java | 8 +- .../ExportDifferentialPricesResponse.java | 8 +- .../responses/ExportInvoicesResponse.java | 8 +- .../responses/ExportItemFamiliesResponse.java | 8 +- .../responses/ExportItemPricesResponse.java | 8 +- .../export/responses/ExportItemsResponse.java | 8 +- .../responses/ExportOrdersResponse.java | 8 +- .../export/responses/ExportPlansResponse.java | 8 +- .../ExportPriceVariantsResponse.java | 8 +- .../responses/ExportRetrieveResponse.java | 8 +- .../ExportRevenueRecognitionResponse.java | 8 +- .../ExportSubscriptionsResponse.java | 8 +- .../responses/ExportTransactionsResponse.java | 8 +- .../chargebee/v4/models/feature/Feature.java | 74 +- .../responses/FeatureActivateResponse.java | 8 +- .../responses/FeatureArchiveResponse.java | 8 +- .../responses/FeatureCreateResponse.java | 8 +- .../responses/FeatureDeleteResponse.java | 8 +- .../responses/FeatureListResponse.java | 25 +- .../responses/FeatureReactivateResponse.java | 8 +- .../responses/FeatureRetrieveResponse.java | 8 +- .../responses/FeatureUpdateResponse.java | 8 +- .../responses/FullExportStatusResponse.java | 4 +- .../GatewayErrorDetail.java | 35 +- .../com/chargebee/v4/models/gift/Gift.java | 72 +- .../gift/responses/GiftCancelResponse.java | 14 +- .../gift/responses/GiftClaimResponse.java | 14 +- .../responses/GiftCreateForItemsResponse.java | 20 +- .../gift/responses/GiftCreateResponse.java | 20 +- .../gift/responses/GiftListResponse.java | 31 +- .../gift/responses/GiftRetrieveResponse.java | 14 +- .../gift/responses/UpdateGiftResponse.java | 14 +- .../v4/models/hierarchy/Hierarchy.java | 21 +- .../v4/models/hostedPage/HostedPage.java | 41 +- .../HostedPageAcceptQuoteResponse.java | 8 +- .../HostedPageAcknowledgeResponse.java | 8 +- ...dPageCheckoutExistingForItemsResponse.java | 8 +- .../HostedPageCheckoutExistingResponse.java | 8 +- ...ostedPageCheckoutGiftForItemsResponse.java | 8 +- .../HostedPageCheckoutGiftResponse.java | 8 +- ...HostedPageCheckoutNewForItemsResponse.java | 8 +- .../HostedPageCheckoutNewResponse.java | 8 +- ...edPageCheckoutOneTimeForItemsResponse.java | 8 +- .../HostedPageCheckoutOneTimeResponse.java | 8 +- .../HostedPageClaimGiftResponse.java | 8 +- .../HostedPageCollectNowResponse.java | 8 +- .../responses/HostedPageEventsResponse.java | 4 +- .../HostedPageExtendSubscriptionResponse.java | 8 +- .../responses/HostedPageListResponse.java | 25 +- ...ostedPageManagePaymentSourcesResponse.java | 8 +- .../HostedPagePreCancelResponse.java | 8 +- ...ostedPageRetrieveAgreementPdfResponse.java | 8 +- .../responses/HostedPageRetrieveResponse.java | 8 +- .../HostedPageUpdateCardResponse.java | 8 +- ...HostedPageUpdatePaymentMethodResponse.java | 8 +- .../HostedPageViewVoucherResponse.java | 8 +- .../impactedCustomer/ImpactedCustomer.java | 23 +- .../v4/models/impactedItem/ImpactedItem.java | 31 +- .../impactedItemPrice/ImpactedItemPrice.java | 31 +- .../ImpactedSubscription.java | 32 +- .../inAppSubscription/InAppSubscription.java | 17 +- ...nAppSubscriptionImportReceiptResponse.java | 7 +- ...ubscriptionImportSubscriptionResponse.java | 8 +- ...AppSubscriptionProcessReceiptResponse.java | 8 +- ...ionRetrieveStoreSubscriptionsResponse.java | 7 +- .../chargebee/v4/models/invoice/Invoice.java | 694 +++++---- .../responses/DownloadEinvoiceResponse.java | 11 +- .../responses/ImportInvoiceResponse.java | 14 +- .../InvoiceAddAddonChargeResponse.java | 8 +- .../InvoiceAddChargeItemResponse.java | 8 +- .../responses/InvoiceAddChargeResponse.java | 8 +- .../InvoiceApplyCreditsResponse.java | 8 +- ...iceApplyPaymentScheduleSchemeResponse.java | 8 +- .../InvoiceApplyPaymentsResponse.java | 8 +- .../responses/InvoiceChargeAddonResponse.java | 8 +- .../responses/InvoiceChargeResponse.java | 8 +- .../responses/InvoiceCloseResponse.java | 8 +- .../InvoiceCollectPaymentResponse.java | 14 +- .../InvoiceCreateForChargeItemResponse.java | 8 +- ...reateForChargeItemsAndChargesResponse.java | 8 +- .../responses/InvoiceCreateResponse.java | 8 +- .../InvoiceDeleteImportedResponse.java | 12 +- .../InvoiceDeleteLineItemsResponse.java | 8 +- .../responses/InvoiceDeleteResponse.java | 8 +- ...ceListPaymentReferenceNumbersResponse.java | 30 +- .../responses/InvoiceListResponse.java | 25 +- .../InvoicePauseDunningResponse.java | 8 +- .../InvoicePaymentSchedulesResponse.java | 12 +- .../invoice/responses/InvoicePdfResponse.java | 8 +- .../InvoiceRecordPaymentResponse.java | 14 +- .../InvoiceRecordRefundResponse.java | 20 +- .../InvoiceRecordTaxWithheldResponse.java | 8 +- .../responses/InvoiceRefundResponse.java | 20 +- .../InvoiceRemoveCreditNoteResponse.java | 14 +- .../InvoiceRemovePaymentResponse.java | 14 +- .../InvoiceRemoveTaxWithheldResponse.java | 8 +- .../InvoiceResumeDunningResponse.java | 8 +- .../responses/InvoiceRetrieveResponse.java | 8 +- .../responses/InvoiceStopDunningResponse.java | 8 +- .../responses/InvoiceSyncUsagesResponse.java | 8 +- .../InvoiceUpdateDetailsResponse.java | 8 +- .../responses/InvoiceWriteOffResponse.java | 14 +- .../InvoicesForCustomerResponse.java | 27 +- .../InvoicesForSubscriptionResponse.java | 27 +- .../responses/ResendEinvoiceResponse.java | 8 +- .../responses/SendEinvoiceResponse.java | 8 +- .../responses/VoidInvoiceResponse.java | 14 +- .../invoiceEstimate/InvoiceEstimate.java | 263 ++-- .../com/chargebee/v4/models/item/Item.java | 134 +- .../item/responses/ItemCreateResponse.java | 8 +- .../item/responses/ItemDeleteResponse.java | 8 +- .../item/responses/ItemListResponse.java | 25 +- .../item/responses/ItemRetrieveResponse.java | 8 +- .../item/responses/ItemUpdateResponse.java | 8 +- .../itemEntitlement/ItemEntitlement.java | 19 +- .../AddItemEntitlementsResponse.java | 8 +- .../ItemEntitlementsForFeatureResponse.java | 29 +- .../ItemEntitlementsForItemResponse.java | 29 +- ...RemoveItemEntitlementsForItemResponse.java | 8 +- .../v4/models/itemFamily/ItemFamily.java | 57 +- .../responses/ItemFamilyCreateResponse.java | 8 +- .../responses/ItemFamilyDeleteResponse.java | 8 +- .../responses/ItemFamilyListResponse.java | 25 +- .../responses/ItemFamilyRetrieveResponse.java | 8 +- .../responses/ItemFamilyUpdateResponse.java | 8 +- .../v4/models/itemPrice/ItemPrice.java | 208 ++- .../FindApplicableItemPricesResponse.java | 29 +- .../responses/ItemPriceCreateResponse.java | 8 +- .../responses/ItemPriceDeleteResponse.java | 8 +- .../ItemPriceFindApplicableItemsResponse.java | 27 +- .../responses/ItemPriceListResponse.java | 25 +- .../responses/ItemPriceRetrieveResponse.java | 8 +- .../responses/ItemPriceUpdateResponse.java | 8 +- .../com/chargebee/v4/models/media/Media.java | 13 +- .../CreateMediaAndAttachToItemResponse.java | 8 +- .../v4/models/metadata/Metadata.java | 7 +- .../nonSubscription/NonSubscription.java | 13 +- ...NonSubscriptionProcessReceiptResponse.java | 8 +- .../responses/OfferEventsResponse.java | 3 + .../offerFulfillment/OfferFulfillment.java | 37 +- .../OfferFulfillmentsGetResponse.java | 8 +- .../responses/OfferFulfillmentsResponse.java | 14 +- .../OfferFulfillmentsUpdateResponse.java | 8 +- .../OmnichannelOneTimeOrder.java | 105 +- .../OmnichannelOneTimeOrderListResponse.java | 28 +- ...nichannelOneTimeOrderRetrieveResponse.java | 9 +- .../OmnichannelOneTimeOrderItem.java | 21 +- .../OmnichannelSubscription.java | 192 ++- .../OmnichannelSubscriptionListResponse.java | 28 +- .../OmnichannelSubscriptionMoveResponse.java | 9 +- ...nichannelSubscriptionRetrieveResponse.java | 9 +- ...onsForOmnichannelSubscriptionResponse.java | 37 +- .../OmnichannelSubscriptionItem.java | 107 +- ...bscriptionItemScheduleChangesResponse.java | 32 +- .../OmnichannelSubscriptionItemOffer.java | 35 +- ...hannelSubscriptionItemScheduledChange.java | 43 +- .../OmnichannelTransaction.java | 51 +- .../com/chargebee/v4/models/order/Order.java | 321 ++-- .../responses/AssignOrderNumberResponse.java | 8 +- .../order/responses/ImportOrderResponse.java | 8 +- .../order/responses/OrderCancelResponse.java | 8 +- ...derCreateRefundableCreditNoteResponse.java | 8 +- .../order/responses/OrderCreateResponse.java | 8 +- .../order/responses/OrderDeleteResponse.java | 8 +- .../order/responses/OrderListResponse.java | 25 +- .../order/responses/OrderReopenResponse.java | 8 +- .../order/responses/OrderResendResponse.java | 8 +- .../responses/OrderRetrieveResponse.java | 8 +- .../order/responses/OrderUpdateResponse.java | 8 +- .../responses/OrdersForInvoiceResponse.java | 27 +- .../models/paymentIntent/PaymentIntent.java | 175 ++- .../PaymentIntentCreateResponse.java | 8 +- .../PaymentIntentRetrieveResponse.java | 8 +- .../PaymentIntentUpdateResponse.java | 8 +- .../PaymentReferenceNumber.java | 13 +- .../paymentSchedule/PaymentSchedule.java | 40 +- .../PaymentScheduleEstimate.java | 34 +- .../PaymentScheduleScheme.java | 36 +- .../PaymentScheduleSchemeCreateResponse.java | 9 +- .../PaymentScheduleSchemeDeleteResponse.java | 9 +- ...PaymentScheduleSchemeRetrieveResponse.java | 9 +- .../models/paymentSource/PaymentSource.java | 241 +-- .../CreateVoucherPaymentSourceResponse.java | 14 +- .../ExportPaymentSourceResponse.java | 9 +- .../PaymentSourceAgreementPdfResponse.java | 8 +- ...aymentSourceCreateBankAccountResponse.java | 14 +- .../PaymentSourceCreateCardResponse.java | 14 +- ...ourceCreateUsingPaymentIntentResponse.java | 14 +- ...urceCreateUsingPermanentTokenResponse.java | 14 +- ...entSourceCreateUsingTempTokenResponse.java | 14 +- ...PaymentSourceCreateUsingTokenResponse.java | 14 +- .../PaymentSourceDeleteLocalResponse.java | 14 +- .../PaymentSourceDeleteResponse.java | 14 +- .../responses/PaymentSourceListResponse.java | 27 +- .../PaymentSourceRetrieveResponse.java | 8 +- ...entSourceSwitchGatewayAccountResponse.java | 14 +- ...aymentSourceUpdateBankAccountResponse.java | 14 +- .../PaymentSourceUpdateCardResponse.java | 14 +- ...aymentSourceVerifyBankAccountResponse.java | 8 +- .../models/paymentVoucher/PaymentVoucher.java | 58 +- .../PaymentVoucherCreateResponse.java | 8 +- .../PaymentVoucherRetrieveResponse.java | 8 +- .../PaymentVouchersForCustomerResponse.java | 29 +- .../PaymentVouchersForInvoiceResponse.java | 29 +- .../Pc2MigrationContactSupportResponse.java | 3 + .../responses/Pc2MigrationCreateResponse.java | 3 + .../Pc2MigrationInitiateResponse.java | 3 + .../Pc2MigrationRetrieveResponse.java | 4 +- .../Pc2MigrationItemCreateResponse.java | 3 + .../Pc2MigrationItemDeleteResponse.java | 4 +- ...ationItemListApplicableAddonsResponse.java | 15 +- .../Pc2MigrationItemListResponse.java | 15 +- .../Pc2MigrationItemRetrieveResponse.java | 4 +- .../Pc2MigrationItemUpdateResponse.java | 3 + .../Pc2MigrationItemFamilyCreateResponse.java | 3 + .../Pc2MigrationItemFamilyDeleteResponse.java | 4 +- .../Pc2MigrationItemFamilyListResponse.java | 15 +- ...c2MigrationItemFamilyRetrieveResponse.java | 4 +- .../Pc2MigrationItemFamilyUpdateResponse.java | 3 + .../Pc2MigrationItemPriceDeleteResponse.java | 4 +- .../Pc2MigrationItemPriceListResponse.java | 15 +- ...Pc2MigrationItemPriceRetrieveResponse.java | 4 +- .../Pc2MigrationItemPriceUpdateResponse.java | 3 + .../personalizedOffer/PersonalizedOffer.java | 43 +- .../responses/PersonalizedOffersResponse.java | 15 +- .../com/chargebee/v4/models/plan/Plan.java | 236 ++- .../plan/responses/PlanCopyResponse.java | 8 +- .../plan/responses/PlanCreateResponse.java | 8 +- .../plan/responses/PlanDeleteResponse.java | 8 +- .../plan/responses/PlanListResponse.java | 25 +- .../plan/responses/PlanRetrieveResponse.java | 8 +- .../plan/responses/PlanUnarchiveResponse.java | 8 +- .../plan/responses/PlanUpdateResponse.java | 8 +- .../models/portalSession/PortalSession.java | 48 +- .../PortalSessionActivateResponse.java | 8 +- .../PortalSessionCreateResponse.java | 8 +- .../PortalSessionLogoutResponse.java | 8 +- .../PortalSessionRetrieveResponse.java | 8 +- .../v4/models/priceVariant/PriceVariant.java | 41 +- .../responses/PriceVariantCreateResponse.java | 8 +- .../responses/PriceVariantDeleteResponse.java | 8 +- .../responses/PriceVariantListResponse.java | 25 +- .../PriceVariantRetrieveResponse.java | 8 +- .../responses/PriceVariantUpdateResponse.java | 8 +- .../PricingPageSession.java | 13 +- ...CreateForExistingSubscriptionResponse.java | 8 +- ...ssionCreateForNewSubscriptionResponse.java | 8 +- .../chargebee/v4/models/product/Product.java | 60 +- .../responses/ProductCreateResponse.java | 8 +- .../responses/ProductDeleteResponse.java | 8 +- .../responses/ProductListResponse.java | 25 +- .../responses/ProductRetrieveResponse.java | 8 +- .../ProductUpdateOptionsResponse.java | 8 +- .../responses/ProductUpdateResponse.java | 8 +- .../promotionalCredit/PromotionalCredit.java | 31 +- .../PromotionalCreditAddResponse.java | 14 +- .../PromotionalCreditDeductResponse.java | 14 +- .../PromotionalCreditListResponse.java | 27 +- .../PromotionalCreditRetrieveResponse.java | 8 +- .../PromotionalCreditSetResponse.java | 14 +- .../v4/models/purchase/Purchase.java | 24 +- .../responses/PurchaseCreateResponse.java | 8 +- .../responses/PurchaseEstimateResponse.java | 8 +- .../com/chargebee/v4/models/quote/Quote.java | 371 +++-- ...eSubscriptionForCustomerQuoteResponse.java | 14 +- ...criptionItemsForCustomerQuoteResponse.java | 20 +- ...criptionCustomerQuoteForItemsResponse.java | 20 +- ...eSubscriptionForCustomerQuoteResponse.java | 14 +- .../responses/EditOneTimeQuoteResponse.java | 14 +- ...dateSubscriptionQuoteForItemsResponse.java | 20 +- .../EditUpdateSubscriptionQuoteResponse.java | 14 +- .../quote/responses/QuoteConvertResponse.java | 55 +- ...reateForChargeItemsAndChargesResponse.java | 14 +- .../QuoteCreateForOnetimeChargesResponse.java | 14 +- .../quote/responses/QuoteDeleteResponse.java | 26 +- ...eEditForChargeItemsAndChargesResponse.java | 14 +- .../QuoteExtendExpiryDateResponse.java | 26 +- .../QuoteLineGroupsForQuoteResponse.java | 27 +- .../quote/responses/QuoteListResponse.java | 37 +- .../quote/responses/QuotePdfResponse.java | 8 +- .../responses/QuoteRetrieveResponse.java | 26 +- .../responses/QuoteUpdateStatusResponse.java | 26 +- ...dateSubscriptionQuoteForItemsResponse.java | 20 +- .../UpdateSubscriptionQuoteResponse.java | 14 +- .../models/quoteLineGroup/QuoteLineGroup.java | 176 ++- .../v4/models/quotedCharge/QuotedCharge.java | 130 +- .../quotedDeltaRamp/QuotedDeltaRamp.java | 15 +- .../v4/models/quotedRamp/QuotedRamp.java | 164 +- .../QuotedSubscription.java | 214 +-- .../com/chargebee/v4/models/ramp/Ramp.java | 227 +-- .../RampCreateForSubscriptionResponse.java | 8 +- .../ramp/responses/RampDeleteResponse.java | 8 +- .../ramp/responses/RampListResponse.java | 25 +- .../ramp/responses/RampRetrieveResponse.java | 8 +- .../ramp/responses/RampUpdateResponse.java | 8 +- .../recordedPurchase/RecordedPurchase.java | 61 +- .../RecordedPurchaseCreateResponse.java | 14 +- .../RecordedPurchaseRetrieveResponse.java | 8 +- .../resourceMigration/ResourceMigration.java | 19 +- ...sourceMigrationRetrieveLatestResponse.java | 8 +- .../com/chargebee/v4/models/rule/Rule.java | 25 +- .../rule/responses/RuleRetrieveResponse.java | 8 +- .../v4/models/salesOrder/SalesOrder.java | 316 ++-- .../SiteMigrationDetail.java | 17 +- .../SiteMigrationDetailListResponse.java | 28 +- .../v4/models/subscription/Subscription.java | 533 +++---- .../ContractTermsForSubscriptionResponse.java | 29 +- .../responses/ImportSubscriptionResponse.java | 26 +- ...ubscriptionAddChargeAtTermEndResponse.java | 8 +- .../SubscriptionCancelForItemsResponse.java | 35 +- .../responses/SubscriptionCancelResponse.java | 35 +- .../SubscriptionChangeTermEndResponse.java | 35 +- ...scriptionChargeAddonAtTermEndResponse.java | 8 +- ...scriptionChargeFutureRenewalsResponse.java | 32 +- ...SubscriptionCreateForCustomerResponse.java | 31 +- .../responses/SubscriptionCreateResponse.java | 31 +- .../SubscriptionCreateWithItemsResponse.java | 31 +- .../responses/SubscriptionDeleteResponse.java | 20 +- ...ionEditAdvanceInvoiceScheduleResponse.java | 8 +- ...ubscriptionImportContractTermResponse.java | 8 +- ...SubscriptionImportForCustomerResponse.java | 26 +- .../SubscriptionImportForItemsResponse.java | 26 +- ...criptionImportUnbilledChargesResponse.java | 7 +- .../SubscriptionListDiscountsResponse.java | 27 +- .../responses/SubscriptionListResponse.java | 37 +- .../responses/SubscriptionMoveResponse.java | 8 +- ...riptionOverrideBillingProfileResponse.java | 14 +- .../responses/SubscriptionPauseResponse.java | 35 +- .../SubscriptionReactivateResponse.java | 31 +- ...SubscriptionRegenerateInvoiceResponse.java | 13 +- ...nRemoveAdvanceInvoiceScheduleResponse.java | 14 +- .../SubscriptionRemoveCouponsResponse.java | 20 +- ...onRemoveScheduledCancellationResponse.java | 20 +- ...riptionRemoveScheduledChangesResponse.java | 24 +- ...scriptionRemoveScheduledPauseResponse.java | 20 +- ...tionRemoveScheduledResumptionResponse.java | 20 +- .../responses/SubscriptionResumeResponse.java | 31 +- ...etrieveAdvanceInvoiceScheduleResponse.java | 13 +- .../SubscriptionRetrieveResponse.java | 20 +- ...nRetrieveWithScheduledChangesResponse.java | 20 +- .../SubscriptionUpdateForItemsResponse.java | 35 +- .../responses/SubscriptionUpdateResponse.java | 35 +- .../SubscriptionsForCustomerResponse.java | 29 +- .../SubscriptionEntitlement.java | 54 +- ...iptionEntitlementAvailabilityResponse.java | 7 +- ...onEntitlementsForSubscriptionResponse.java | 31 +- ...SubscriptionEntitlementsCreatedDetail.java | 9 +- ...SubscriptionEntitlementsUpdatedDetail.java | 9 +- .../SubscriptionEstimate.java | 92 +- .../SubscriptionSettingRetrieveResponse.java | 4 +- .../v4/models/taxWithheld/TaxWithheld.java | 29 +- .../ThirdPartyConfiguration.java | 21 +- ...tyConfigurationConfigurationsResponse.java | 9 +- ...irdPartyConfigurationRetrieveResponse.java | 9 +- ...ThirdPartyConfigurationUpdateResponse.java | 9 +- .../ThirdPartyEntityMapping.java | 49 +- ...hirdPartyEntityMappingListAllResponse.java | 9 +- .../ThirdPartyEntityMappingListResponse.java | 28 +- ...tyEntityMappingRetrieveEntityResponse.java | 9 +- ...artyEntityMappingUpdateEntityResponse.java | 9 +- .../ThirdPartyPaymentMethod.java | 13 +- .../ThirdPartySyncDetail.java | 17 +- .../ThirdPartySyncDetailCreateResponse.java | 9 +- ...ySyncDetailRetrieveLatestSyncResponse.java | 9 +- .../ThirdPartySyncDetailRetrieveResponse.java | 9 +- .../ThirdPartySyncDetailUpdateResponse.java | 9 +- .../v4/models/timeMachine/TimeMachine.java | 19 +- .../TimeMachineRetrieveResponse.java | 8 +- .../TimeMachineStartAfreshResponse.java | 8 +- .../TimeMachineTravelForwardResponse.java | 8 +- .../com/chargebee/v4/models/token/Token.java | 29 +- .../v4/models/tpSiteUser/TpSiteUser.java | 11 +- .../GuestsForTpSiteUserResponse.java | 27 +- .../TpSiteUserPayNowEnableLiveResponse.java | 8 +- .../responses/UsersForTpSiteUserResponse.java | 27 +- .../v4/models/transaction/Transaction.java | 209 +-- .../DeleteOfflineTransactionResponse.java | 8 +- .../responses/SyncTransactionResponse.java | 8 +- ...ransactionCreateAuthorizationResponse.java | 8 +- .../responses/TransactionListResponse.java | 25 +- ...TransactionPaymentsForInvoiceResponse.java | 27 +- .../TransactionReconcileResponse.java | 8 +- .../TransactionRecordRefundResponse.java | 8 +- .../responses/TransactionRefundResponse.java | 8 +- .../TransactionRetrieveResponse.java | 8 +- .../TransactionsForCustomerResponse.java | 29 +- .../TransactionsForSubscriptionResponse.java | 29 +- .../responses/VoidTransactionResponse.java | 8 +- .../models/unbilledCharge/UnbilledCharge.java | 80 +- .../CreateUnbilledChargeResponse.java | 7 +- .../InvoiceUnbilledChargesResponse.java | 6 +- .../UnbilledChargeCreateResponse.java | 7 +- .../UnbilledChargeDeleteResponse.java | 8 +- ...illedChargeInvoiceNowEstimateResponse.java | 8 +- .../responses/UnbilledChargeListResponse.java | 27 +- ...nbilledChargesSettingRetrieveResponse.java | 4 +- .../com/chargebee/v4/models/usage/Usage.java | 29 +- .../usage/responses/UsageCreateResponse.java | 8 +- .../usage/responses/UsageDeleteResponse.java | 8 +- .../usage/responses/UsageListResponse.java | 25 +- .../usage/responses/UsagePdfResponse.java | 8 +- .../responses/UsageRetrieveResponse.java | 8 +- .../v4/models/usageEvent/UsageEvent.java | 17 +- .../UsageEventBatchIngestResponse.java | 13 +- .../responses/UsageEventCreateResponse.java | 8 +- .../v4/models/usageFile/UsageFile.java | 51 +- .../UsageFileProcessingStatusResponse.java | 8 +- .../responses/UsageFileUploadUrlResponse.java | 8 +- .../usageReminderInfo/UsageReminderInfo.java | 9 +- .../chargebee/v4/models/variant/Variant.java | 45 +- .../CreateProductVariantResponse.java | 8 +- .../ListProductVariantsResponse.java | 27 +- .../responses/VariantDeleteResponse.java | 8 +- .../responses/VariantRetrieveResponse.java | 8 +- .../responses/VariantUpdateResponse.java | 8 +- .../VirtualBankAccount.java | 35 +- .../VirtualBankAccountCreateResponse.java | 14 +- ...ountCreateUsingPermanentTokenResponse.java | 14 +- ...VirtualBankAccountDeleteLocalResponse.java | 8 +- .../VirtualBankAccountDeleteResponse.java | 8 +- .../VirtualBankAccountListResponse.java | 27 +- .../VirtualBankAccountRetrieveResponse.java | 8 +- .../VirtualBankAccountSyncFundResponse.java | 8 +- .../webhookEndpoint/WebhookEndpoint.java | 27 +- .../WebhookEndpointCreateResponse.java | 8 +- .../WebhookEndpointDeleteResponse.java | 8 +- .../WebhookEndpointListResponse.java | 27 +- .../WebhookEndpointRetrieveResponse.java | 8 +- .../WebhookEndpointUpdateResponse.java | 8 +- 818 files changed, 15135 insertions(+), 11061 deletions(-) diff --git a/src/main/java/com/chargebee/v4/models/additionalBillingLogiq/responses/AdditionalBillingLogiqRetrieveResponse.java b/src/main/java/com/chargebee/v4/models/additionalBillingLogiq/responses/AdditionalBillingLogiqRetrieveResponse.java index ce3cf97e..59618cd5 100644 --- a/src/main/java/com/chargebee/v4/models/additionalBillingLogiq/responses/AdditionalBillingLogiqRetrieveResponse.java +++ b/src/main/java/com/chargebee/v4/models/additionalBillingLogiq/responses/AdditionalBillingLogiqRetrieveResponse.java @@ -2,6 +2,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -26,9 +27,10 @@ public static AdditionalBillingLogiqRetrieveResponse fromJson(String json) { public static AdditionalBillingLogiqRetrieveResponse fromJson( String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - builder.additionalBillingLogiq(JsonUtil.getObject(json, "additional_billing_logiq")); + builder.additionalBillingLogiq(JsonUtil.getObject(jsonObj, "additional_billing_logiq")); builder.httpResponse(httpResponse); return builder.build(); diff --git a/src/main/java/com/chargebee/v4/models/addon/Addon.java b/src/main/java/com/chargebee/v4/models/addon/Addon.java index 04b11d81..19adb1fd 100644 --- a/src/main/java/com/chargebee/v4/models/addon/Addon.java +++ b/src/main/java/com/chargebee/v4/models/addon/Addon.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.addon; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import java.sql.Timestamp; import java.util.List; @@ -545,9 +546,12 @@ public static ProrationType fromString(String value) { } public static Addon fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Addon fromJson(JsonObject jsonObj) { Addon obj = new Addon(); - // Parse JSON to extract all keys for custom field extraction java.util.Set knownFields = new java.util.HashSet<>(); knownFields.add("id"); @@ -638,142 +642,108 @@ public static Addon fromJson(String json) { knownFields.add("tax_providers_fields"); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.name = JsonUtil.getString(json, "name"); + obj.name = JsonUtil.getString(jsonObj, "name"); - obj.invoiceName = JsonUtil.getString(json, "invoice_name"); + obj.invoiceName = JsonUtil.getString(jsonObj, "invoice_name"); - obj.description = JsonUtil.getString(json, "description"); + obj.description = JsonUtil.getString(jsonObj, "description"); - obj.pricingModel = PricingModel.fromString(JsonUtil.getString(json, "pricing_model")); + obj.pricingModel = PricingModel.fromString(JsonUtil.getString(jsonObj, "pricing_model")); - obj.type = Type.fromString(JsonUtil.getString(json, "type")); + obj.type = Type.fromString(JsonUtil.getString(jsonObj, "type")); - obj.chargeType = ChargeType.fromString(JsonUtil.getString(json, "charge_type")); + obj.chargeType = ChargeType.fromString(JsonUtil.getString(jsonObj, "charge_type")); - obj.price = JsonUtil.getLong(json, "price"); + obj.price = JsonUtil.getLong(jsonObj, "price"); - obj.currencyCode = JsonUtil.getString(json, "currency_code"); + obj.currencyCode = JsonUtil.getString(jsonObj, "currency_code"); - obj.period = JsonUtil.getInteger(json, "period"); + obj.period = JsonUtil.getInteger(jsonObj, "period"); - obj.periodUnit = PeriodUnit.fromString(JsonUtil.getString(json, "period_unit")); + obj.periodUnit = PeriodUnit.fromString(JsonUtil.getString(jsonObj, "period_unit")); - obj.unit = JsonUtil.getString(json, "unit"); + obj.unit = JsonUtil.getString(jsonObj, "unit"); - obj.status = Status.fromString(JsonUtil.getString(json, "status")); + obj.status = Status.fromString(JsonUtil.getString(jsonObj, "status")); - obj.archivedAt = JsonUtil.getTimestamp(json, "archived_at"); + obj.archivedAt = JsonUtil.getTimestamp(jsonObj, "archived_at"); - obj.enabledInPortal = JsonUtil.getBoolean(json, "enabled_in_portal"); + obj.enabledInPortal = JsonUtil.getBoolean(jsonObj, "enabled_in_portal"); - obj.taxCode = JsonUtil.getString(json, "tax_code"); + obj.taxCode = JsonUtil.getString(jsonObj, "tax_code"); - obj.hsnCode = JsonUtil.getString(json, "hsn_code"); + obj.hsnCode = JsonUtil.getString(jsonObj, "hsn_code"); - obj.taxjarProductCode = JsonUtil.getString(json, "taxjar_product_code"); + obj.taxjarProductCode = JsonUtil.getString(jsonObj, "taxjar_product_code"); - obj.avalaraSaleType = AvalaraSaleType.fromString(JsonUtil.getString(json, "avalara_sale_type")); + obj.avalaraSaleType = + AvalaraSaleType.fromString(JsonUtil.getString(jsonObj, "avalara_sale_type")); - obj.avalaraTransactionType = JsonUtil.getInteger(json, "avalara_transaction_type"); + obj.avalaraTransactionType = JsonUtil.getInteger(jsonObj, "avalara_transaction_type"); - obj.avalaraServiceType = JsonUtil.getInteger(json, "avalara_service_type"); + obj.avalaraServiceType = JsonUtil.getInteger(jsonObj, "avalara_service_type"); - obj.sku = JsonUtil.getString(json, "sku"); + obj.sku = JsonUtil.getString(jsonObj, "sku"); - obj.accountingCode = JsonUtil.getString(json, "accounting_code"); + obj.accountingCode = JsonUtil.getString(jsonObj, "accounting_code"); - obj.accountingCategory1 = JsonUtil.getString(json, "accounting_category1"); + obj.accountingCategory1 = JsonUtil.getString(jsonObj, "accounting_category1"); - obj.accountingCategory2 = JsonUtil.getString(json, "accounting_category2"); + obj.accountingCategory2 = JsonUtil.getString(jsonObj, "accounting_category2"); - obj.accountingCategory3 = JsonUtil.getString(json, "accounting_category3"); + obj.accountingCategory3 = JsonUtil.getString(jsonObj, "accounting_category3"); - obj.accountingCategory4 = JsonUtil.getString(json, "accounting_category4"); + obj.accountingCategory4 = JsonUtil.getString(jsonObj, "accounting_category4"); - obj.isShippable = JsonUtil.getBoolean(json, "is_shippable"); + obj.isShippable = JsonUtil.getBoolean(jsonObj, "is_shippable"); - obj.shippingFrequencyPeriod = JsonUtil.getInteger(json, "shipping_frequency_period"); + obj.shippingFrequencyPeriod = JsonUtil.getInteger(jsonObj, "shipping_frequency_period"); obj.shippingFrequencyPeriodUnit = ShippingFrequencyPeriodUnit.fromString( - JsonUtil.getString(json, "shipping_frequency_period_unit")); + JsonUtil.getString(jsonObj, "shipping_frequency_period_unit")); - obj.resourceVersion = JsonUtil.getLong(json, "resource_version"); + obj.resourceVersion = JsonUtil.getLong(jsonObj, "resource_version"); - obj.updatedAt = JsonUtil.getTimestamp(json, "updated_at"); + obj.updatedAt = JsonUtil.getTimestamp(jsonObj, "updated_at"); - obj.priceInDecimal = JsonUtil.getString(json, "price_in_decimal"); + obj.priceInDecimal = JsonUtil.getString(jsonObj, "price_in_decimal"); - obj.includedInMrr = JsonUtil.getBoolean(json, "included_in_mrr"); + obj.includedInMrr = JsonUtil.getBoolean(jsonObj, "included_in_mrr"); - obj.channel = Channel.fromString(JsonUtil.getString(json, "channel")); + obj.channel = Channel.fromString(JsonUtil.getString(jsonObj, "channel")); - obj.prorationType = ProrationType.fromString(JsonUtil.getString(json, "proration_type")); + obj.prorationType = ProrationType.fromString(JsonUtil.getString(jsonObj, "proration_type")); - obj.invoiceNotes = JsonUtil.getString(json, "invoice_notes"); + obj.invoiceNotes = JsonUtil.getString(jsonObj, "invoice_notes"); - obj.taxable = JsonUtil.getBoolean(json, "taxable"); + obj.taxable = JsonUtil.getBoolean(jsonObj, "taxable"); - obj.taxProfileId = JsonUtil.getString(json, "tax_profile_id"); + obj.taxProfileId = JsonUtil.getString(jsonObj, "tax_profile_id"); - String __metaDataJson = JsonUtil.getObject(json, "meta_data"); + JsonObject __metaDataObj = JsonUtil.getJsonObject(jsonObj, "meta_data"); obj.metaData = - __metaDataJson != null - ? JsonUtil.parseJsonObjectToMap(__metaDataJson) + __metaDataObj != null + ? JsonUtil.parseJsonObjectToMap(__metaDataObj) : new java.util.HashMap<>(); - obj.showDescriptionInInvoices = JsonUtil.getBoolean(json, "show_description_in_invoices"); + obj.showDescriptionInInvoices = JsonUtil.getBoolean(jsonObj, "show_description_in_invoices"); - obj.showDescriptionInQuotes = JsonUtil.getBoolean(json, "show_description_in_quotes"); + obj.showDescriptionInQuotes = JsonUtil.getBoolean(jsonObj, "show_description_in_quotes"); - obj.tiers = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "tiers")).stream() - .map(Tiers::fromJson) - .collect(java.util.stream.Collectors.toList()); + obj.tiers = JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "tiers"), Tiers::fromJson); obj.taxProvidersFields = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "tax_providers_fields")).stream() - .map(TaxProvidersFields::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "tax_providers_fields"), TaxProvidersFields::fromJson); - // Extract custom fields (fields starting with cf_) - obj.customFields = extractCustomFields(json, knownFields); + obj.customFields = JsonUtil.extractCustomFields(jsonObj, knownFields); return obj; } - /** - * Helper method to extract custom fields from JSON. Custom fields are fields that start with - * "cf_" and are not in the known fields set. - * - * @param json JSON string to parse - * @param knownFields set of known field names - * @return map of custom fields - */ - private static java.util.Map extractCustomFields( - String json, java.util.Set knownFields) { - java.util.Map customFields = new java.util.HashMap<>(); - try { - // Parse the entire JSON as a map - java.util.Map allFields = JsonUtil.parseJsonObjectToMap(json); - if (allFields != null) { - for (java.util.Map.Entry entry : allFields.entrySet()) { - String key = entry.getKey(); - // Include fields that start with "cf_" and are not in knownFields - if (key != null && key.startsWith("cf_") && !knownFields.contains(key)) { - customFields.put( - key, entry.getValue() != null ? String.valueOf(entry.getValue()) : null); - } - } - } - } catch (Exception e) { - // If parsing fails, return empty map - } - return customFields; - } - @Override public String toString() { return "Addon{" @@ -1048,23 +1018,27 @@ public static PricingType fromString(String value) { } public static Tiers fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Tiers fromJson(JsonObject jsonObj) { Tiers obj = new Tiers(); - obj.startingUnit = JsonUtil.getInteger(json, "starting_unit"); + obj.startingUnit = JsonUtil.getInteger(jsonObj, "starting_unit"); - obj.endingUnit = JsonUtil.getInteger(json, "ending_unit"); + obj.endingUnit = JsonUtil.getInteger(jsonObj, "ending_unit"); - obj.price = JsonUtil.getLong(json, "price"); + obj.price = JsonUtil.getLong(jsonObj, "price"); - obj.startingUnitInDecimal = JsonUtil.getString(json, "starting_unit_in_decimal"); + obj.startingUnitInDecimal = JsonUtil.getString(jsonObj, "starting_unit_in_decimal"); - obj.endingUnitInDecimal = JsonUtil.getString(json, "ending_unit_in_decimal"); + obj.endingUnitInDecimal = JsonUtil.getString(jsonObj, "ending_unit_in_decimal"); - obj.priceInDecimal = JsonUtil.getString(json, "price_in_decimal"); + obj.priceInDecimal = JsonUtil.getString(jsonObj, "price_in_decimal"); - obj.pricingType = PricingType.fromString(JsonUtil.getString(json, "pricing_type")); + obj.pricingType = PricingType.fromString(JsonUtil.getString(jsonObj, "pricing_type")); - obj.packageSize = JsonUtil.getInteger(json, "package_size"); + obj.packageSize = JsonUtil.getInteger(jsonObj, "package_size"); return obj; } @@ -1141,13 +1115,17 @@ public String getFieldValue() { } public static TaxProvidersFields fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static TaxProvidersFields fromJson(JsonObject jsonObj) { TaxProvidersFields obj = new TaxProvidersFields(); - obj.providerName = JsonUtil.getString(json, "provider_name"); + obj.providerName = JsonUtil.getString(jsonObj, "provider_name"); - obj.fieldId = JsonUtil.getString(json, "field_id"); + obj.fieldId = JsonUtil.getString(jsonObj, "field_id"); - obj.fieldValue = JsonUtil.getString(json, "field_value"); + obj.fieldValue = JsonUtil.getString(jsonObj, "field_value"); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/addon/responses/AddonCopyResponse.java b/src/main/java/com/chargebee/v4/models/addon/responses/AddonCopyResponse.java index 8394fcc0..608b75ae 100644 --- a/src/main/java/com/chargebee/v4/models/addon/responses/AddonCopyResponse.java +++ b/src/main/java/com/chargebee/v4/models/addon/responses/AddonCopyResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** Immutable response object for AddonCopy operation. Contains the response data from the API. */ @@ -24,11 +25,12 @@ public static AddonCopyResponse fromJson(String json) { /** Parse JSON response into AddonCopyResponse object with HTTP response. */ public static AddonCopyResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __addonJson = JsonUtil.getObject(json, "addon"); - if (__addonJson != null) { - builder.addon(Addon.fromJson(__addonJson)); + JsonObject __addonObj = JsonUtil.getJsonObject(jsonObj, "addon"); + if (__addonObj != null) { + builder.addon(Addon.fromJson(__addonObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/addon/responses/AddonCreateResponse.java b/src/main/java/com/chargebee/v4/models/addon/responses/AddonCreateResponse.java index c3f9eec0..e5f8ac5a 100644 --- a/src/main/java/com/chargebee/v4/models/addon/responses/AddonCreateResponse.java +++ b/src/main/java/com/chargebee/v4/models/addon/responses/AddonCreateResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** Immutable response object for AddonCreate operation. Contains the response data from the API. */ @@ -24,11 +25,12 @@ public static AddonCreateResponse fromJson(String json) { /** Parse JSON response into AddonCreateResponse object with HTTP response. */ public static AddonCreateResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __addonJson = JsonUtil.getObject(json, "addon"); - if (__addonJson != null) { - builder.addon(Addon.fromJson(__addonJson)); + JsonObject __addonObj = JsonUtil.getJsonObject(jsonObj, "addon"); + if (__addonObj != null) { + builder.addon(Addon.fromJson(__addonObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/addon/responses/AddonDeleteResponse.java b/src/main/java/com/chargebee/v4/models/addon/responses/AddonDeleteResponse.java index f84bb953..e341089a 100644 --- a/src/main/java/com/chargebee/v4/models/addon/responses/AddonDeleteResponse.java +++ b/src/main/java/com/chargebee/v4/models/addon/responses/AddonDeleteResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** Immutable response object for AddonDelete operation. Contains the response data from the API. */ @@ -24,11 +25,12 @@ public static AddonDeleteResponse fromJson(String json) { /** Parse JSON response into AddonDeleteResponse object with HTTP response. */ public static AddonDeleteResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __addonJson = JsonUtil.getObject(json, "addon"); - if (__addonJson != null) { - builder.addon(Addon.fromJson(__addonJson)); + JsonObject __addonObj = JsonUtil.getJsonObject(jsonObj, "addon"); + if (__addonObj != null) { + builder.addon(Addon.fromJson(__addonObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/addon/responses/AddonListResponse.java b/src/main/java/com/chargebee/v4/models/addon/responses/AddonListResponse.java index fb41efd7..2ebcf8ce 100644 --- a/src/main/java/com/chargebee/v4/models/addon/responses/AddonListResponse.java +++ b/src/main/java/com/chargebee/v4/models/addon/responses/AddonListResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.exceptions.ChargebeeException; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; import com.chargebee.v4.services.AddonService; import com.chargebee.v4.models.addon.params.AddonListParams; @@ -43,13 +44,12 @@ private AddonListResponse( */ public static AddonListResponse fromJson(String json) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(AddonListItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "list"), AddonListItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new AddonListResponse(list, nextOffset, null, null, null); } catch (Exception e) { @@ -64,13 +64,12 @@ public static AddonListResponse fromJson(String json) { public static AddonListResponse fromJson( String json, AddonService service, AddonListParams originalParams, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(AddonListItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "list"), AddonListItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new AddonListResponse(list, nextOffset, service, originalParams, httpResponse); } catch (Exception e) { @@ -170,11 +169,15 @@ public Addon getAddon() { } public static AddonListItem fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static AddonListItem fromJson(JsonObject jsonObj) { AddonListItem item = new AddonListItem(); - String __addonJson = JsonUtil.getObject(json, "addon"); - if (__addonJson != null) { - item.addon = Addon.fromJson(__addonJson); + JsonObject __addonObj = JsonUtil.getJsonObject(jsonObj, "addon"); + if (__addonObj != null) { + item.addon = Addon.fromJson(__addonObj); } return item; diff --git a/src/main/java/com/chargebee/v4/models/addon/responses/AddonRetrieveResponse.java b/src/main/java/com/chargebee/v4/models/addon/responses/AddonRetrieveResponse.java index b66b9a82..5f7bf550 100644 --- a/src/main/java/com/chargebee/v4/models/addon/responses/AddonRetrieveResponse.java +++ b/src/main/java/com/chargebee/v4/models/addon/responses/AddonRetrieveResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static AddonRetrieveResponse fromJson(String json) { /** Parse JSON response into AddonRetrieveResponse object with HTTP response. */ public static AddonRetrieveResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __addonJson = JsonUtil.getObject(json, "addon"); - if (__addonJson != null) { - builder.addon(Addon.fromJson(__addonJson)); + JsonObject __addonObj = JsonUtil.getJsonObject(jsonObj, "addon"); + if (__addonObj != null) { + builder.addon(Addon.fromJson(__addonObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/addon/responses/AddonUnarchiveResponse.java b/src/main/java/com/chargebee/v4/models/addon/responses/AddonUnarchiveResponse.java index ef8858e2..2d9bdc3a 100644 --- a/src/main/java/com/chargebee/v4/models/addon/responses/AddonUnarchiveResponse.java +++ b/src/main/java/com/chargebee/v4/models/addon/responses/AddonUnarchiveResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -26,11 +27,12 @@ public static AddonUnarchiveResponse fromJson(String json) { /** Parse JSON response into AddonUnarchiveResponse object with HTTP response. */ public static AddonUnarchiveResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __addonJson = JsonUtil.getObject(json, "addon"); - if (__addonJson != null) { - builder.addon(Addon.fromJson(__addonJson)); + JsonObject __addonObj = JsonUtil.getJsonObject(jsonObj, "addon"); + if (__addonObj != null) { + builder.addon(Addon.fromJson(__addonObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/addon/responses/AddonUpdateResponse.java b/src/main/java/com/chargebee/v4/models/addon/responses/AddonUpdateResponse.java index a6d56710..ffb34679 100644 --- a/src/main/java/com/chargebee/v4/models/addon/responses/AddonUpdateResponse.java +++ b/src/main/java/com/chargebee/v4/models/addon/responses/AddonUpdateResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** Immutable response object for AddonUpdate operation. Contains the response data from the API. */ @@ -24,11 +25,12 @@ public static AddonUpdateResponse fromJson(String json) { /** Parse JSON response into AddonUpdateResponse object with HTTP response. */ public static AddonUpdateResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __addonJson = JsonUtil.getObject(json, "addon"); - if (__addonJson != null) { - builder.addon(Addon.fromJson(__addonJson)); + JsonObject __addonObj = JsonUtil.getJsonObject(jsonObj, "addon"); + if (__addonObj != null) { + builder.addon(Addon.fromJson(__addonObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/address/Address.java b/src/main/java/com/chargebee/v4/models/address/Address.java index f0ff2c74..f4438fb2 100644 --- a/src/main/java/com/chargebee/v4/models/address/Address.java +++ b/src/main/java/com/chargebee/v4/models/address/Address.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.address; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; public class Address { @@ -125,40 +126,44 @@ public static ValidationStatus fromString(String value) { } public static Address fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Address fromJson(JsonObject jsonObj) { Address obj = new Address(); - obj.label = JsonUtil.getString(json, "label"); + obj.label = JsonUtil.getString(jsonObj, "label"); - obj.firstName = JsonUtil.getString(json, "first_name"); + obj.firstName = JsonUtil.getString(jsonObj, "first_name"); - obj.lastName = JsonUtil.getString(json, "last_name"); + obj.lastName = JsonUtil.getString(jsonObj, "last_name"); - obj.email = JsonUtil.getString(json, "email"); + obj.email = JsonUtil.getString(jsonObj, "email"); - obj.company = JsonUtil.getString(json, "company"); + obj.company = JsonUtil.getString(jsonObj, "company"); - obj.phone = JsonUtil.getString(json, "phone"); + obj.phone = JsonUtil.getString(jsonObj, "phone"); - obj.addr = JsonUtil.getString(json, "addr"); + obj.addr = JsonUtil.getString(jsonObj, "addr"); - obj.extendedAddr = JsonUtil.getString(json, "extended_addr"); + obj.extendedAddr = JsonUtil.getString(jsonObj, "extended_addr"); - obj.extendedAddr2 = JsonUtil.getString(json, "extended_addr2"); + obj.extendedAddr2 = JsonUtil.getString(jsonObj, "extended_addr2"); - obj.city = JsonUtil.getString(json, "city"); + obj.city = JsonUtil.getString(jsonObj, "city"); - obj.stateCode = JsonUtil.getString(json, "state_code"); + obj.stateCode = JsonUtil.getString(jsonObj, "state_code"); - obj.state = JsonUtil.getString(json, "state"); + obj.state = JsonUtil.getString(jsonObj, "state"); - obj.country = JsonUtil.getString(json, "country"); + obj.country = JsonUtil.getString(jsonObj, "country"); - obj.zip = JsonUtil.getString(json, "zip"); + obj.zip = JsonUtil.getString(jsonObj, "zip"); obj.validationStatus = - ValidationStatus.fromString(JsonUtil.getString(json, "validation_status")); + ValidationStatus.fromString(JsonUtil.getString(jsonObj, "validation_status")); - obj.subscriptionId = JsonUtil.getString(json, "subscription_id"); + obj.subscriptionId = JsonUtil.getString(jsonObj, "subscription_id"); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/address/responses/AddressRetrieveResponse.java b/src/main/java/com/chargebee/v4/models/address/responses/AddressRetrieveResponse.java index 3f1863ba..871ecdc9 100644 --- a/src/main/java/com/chargebee/v4/models/address/responses/AddressRetrieveResponse.java +++ b/src/main/java/com/chargebee/v4/models/address/responses/AddressRetrieveResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static AddressRetrieveResponse fromJson(String json) { /** Parse JSON response into AddressRetrieveResponse object with HTTP response. */ public static AddressRetrieveResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __addressJson = JsonUtil.getObject(json, "address"); - if (__addressJson != null) { - builder.address(Address.fromJson(__addressJson)); + JsonObject __addressObj = JsonUtil.getJsonObject(jsonObj, "address"); + if (__addressObj != null) { + builder.address(Address.fromJson(__addressObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/address/responses/AddressUpdateResponse.java b/src/main/java/com/chargebee/v4/models/address/responses/AddressUpdateResponse.java index 858ea743..b410572c 100644 --- a/src/main/java/com/chargebee/v4/models/address/responses/AddressUpdateResponse.java +++ b/src/main/java/com/chargebee/v4/models/address/responses/AddressUpdateResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -26,11 +27,12 @@ public static AddressUpdateResponse fromJson(String json) { /** Parse JSON response into AddressUpdateResponse object with HTTP response. */ public static AddressUpdateResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __addressJson = JsonUtil.getObject(json, "address"); - if (__addressJson != null) { - builder.address(Address.fromJson(__addressJson)); + JsonObject __addressObj = JsonUtil.getJsonObject(jsonObj, "address"); + if (__addressObj != null) { + builder.address(Address.fromJson(__addressObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/advanceInvoiceSchedule/AdvanceInvoiceSchedule.java b/src/main/java/com/chargebee/v4/models/advanceInvoiceSchedule/AdvanceInvoiceSchedule.java index 434b7d07..992ba14c 100644 --- a/src/main/java/com/chargebee/v4/models/advanceInvoiceSchedule/AdvanceInvoiceSchedule.java +++ b/src/main/java/com/chargebee/v4/models/advanceInvoiceSchedule/AdvanceInvoiceSchedule.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.advanceInvoiceSchedule; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import java.sql.Timestamp; public class AdvanceInvoiceSchedule { @@ -62,20 +63,26 @@ public static ScheduleType fromString(String value) { } public static AdvanceInvoiceSchedule fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static AdvanceInvoiceSchedule fromJson(JsonObject jsonObj) { AdvanceInvoiceSchedule obj = new AdvanceInvoiceSchedule(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.scheduleType = ScheduleType.fromString(JsonUtil.getString(json, "schedule_type")); + obj.scheduleType = ScheduleType.fromString(JsonUtil.getString(jsonObj, "schedule_type")); - String __fixedIntervalScheduleJson = JsonUtil.getObject(json, "fixed_interval_schedule"); - if (__fixedIntervalScheduleJson != null) { - obj.fixedIntervalSchedule = FixedIntervalSchedule.fromJson(__fixedIntervalScheduleJson); + JsonObject __fixedIntervalScheduleObj = + JsonUtil.getJsonObject(jsonObj, "fixed_interval_schedule"); + if (__fixedIntervalScheduleObj != null) { + obj.fixedIntervalSchedule = FixedIntervalSchedule.fromJson(__fixedIntervalScheduleObj); } - String __specificDatesScheduleJson = JsonUtil.getObject(json, "specific_dates_schedule"); - if (__specificDatesScheduleJson != null) { - obj.specificDatesSchedule = SpecificDatesSchedule.fromJson(__specificDatesScheduleJson); + JsonObject __specificDatesScheduleObj = + JsonUtil.getJsonObject(jsonObj, "specific_dates_schedule"); + if (__specificDatesScheduleObj != null) { + obj.specificDatesSchedule = SpecificDatesSchedule.fromJson(__specificDatesScheduleObj); } return obj; @@ -177,19 +184,23 @@ public static EndScheduleOn fromString(String value) { } public static FixedIntervalSchedule fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static FixedIntervalSchedule fromJson(JsonObject jsonObj) { FixedIntervalSchedule obj = new FixedIntervalSchedule(); - obj.endScheduleOn = EndScheduleOn.fromString(JsonUtil.getString(json, "end_schedule_on")); + obj.endScheduleOn = EndScheduleOn.fromString(JsonUtil.getString(jsonObj, "end_schedule_on")); - obj.numberOfOccurrences = JsonUtil.getInteger(json, "number_of_occurrences"); + obj.numberOfOccurrences = JsonUtil.getInteger(jsonObj, "number_of_occurrences"); - obj.daysBeforeRenewal = JsonUtil.getInteger(json, "days_before_renewal"); + obj.daysBeforeRenewal = JsonUtil.getInteger(jsonObj, "days_before_renewal"); - obj.endDate = JsonUtil.getTimestamp(json, "end_date"); + obj.endDate = JsonUtil.getTimestamp(jsonObj, "end_date"); - obj.createdAt = JsonUtil.getTimestamp(json, "created_at"); + obj.createdAt = JsonUtil.getTimestamp(jsonObj, "created_at"); - obj.termsToCharge = JsonUtil.getInteger(json, "terms_to_charge"); + obj.termsToCharge = JsonUtil.getInteger(jsonObj, "terms_to_charge"); return obj; } @@ -253,13 +264,17 @@ public Timestamp getCreatedAt() { } public static SpecificDatesSchedule fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static SpecificDatesSchedule fromJson(JsonObject jsonObj) { SpecificDatesSchedule obj = new SpecificDatesSchedule(); - obj.termsToCharge = JsonUtil.getInteger(json, "terms_to_charge"); + obj.termsToCharge = JsonUtil.getInteger(jsonObj, "terms_to_charge"); - obj.date = JsonUtil.getTimestamp(json, "date"); + obj.date = JsonUtil.getTimestamp(jsonObj, "date"); - obj.createdAt = JsonUtil.getTimestamp(json, "created_at"); + obj.createdAt = JsonUtil.getTimestamp(jsonObj, "created_at"); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/attachedItem/AttachedItem.java b/src/main/java/com/chargebee/v4/models/attachedItem/AttachedItem.java index 56a70471..1e2a4069 100644 --- a/src/main/java/com/chargebee/v4/models/attachedItem/AttachedItem.java +++ b/src/main/java/com/chargebee/v4/models/attachedItem/AttachedItem.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.attachedItem; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import java.sql.Timestamp; public class AttachedItem { @@ -220,39 +221,43 @@ public static Channel fromString(String value) { } public static AttachedItem fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static AttachedItem fromJson(JsonObject jsonObj) { AttachedItem obj = new AttachedItem(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.parentItemId = JsonUtil.getString(json, "parent_item_id"); + obj.parentItemId = JsonUtil.getString(jsonObj, "parent_item_id"); - obj.itemId = JsonUtil.getString(json, "item_id"); + obj.itemId = JsonUtil.getString(jsonObj, "item_id"); - obj.type = Type.fromString(JsonUtil.getString(json, "type")); + obj.type = Type.fromString(JsonUtil.getString(jsonObj, "type")); - obj.status = Status.fromString(JsonUtil.getString(json, "status")); + obj.status = Status.fromString(JsonUtil.getString(jsonObj, "status")); - obj.quantity = JsonUtil.getInteger(json, "quantity"); + obj.quantity = JsonUtil.getInteger(jsonObj, "quantity"); - obj.quantityInDecimal = JsonUtil.getString(json, "quantity_in_decimal"); + obj.quantityInDecimal = JsonUtil.getString(jsonObj, "quantity_in_decimal"); - obj.billingCycles = JsonUtil.getInteger(json, "billing_cycles"); + obj.billingCycles = JsonUtil.getInteger(jsonObj, "billing_cycles"); - obj.chargeOnEvent = ChargeOnEvent.fromString(JsonUtil.getString(json, "charge_on_event")); + obj.chargeOnEvent = ChargeOnEvent.fromString(JsonUtil.getString(jsonObj, "charge_on_event")); - obj.chargeOnce = JsonUtil.getBoolean(json, "charge_once"); + obj.chargeOnce = JsonUtil.getBoolean(jsonObj, "charge_once"); - obj.createdAt = JsonUtil.getTimestamp(json, "created_at"); + obj.createdAt = JsonUtil.getTimestamp(jsonObj, "created_at"); - obj.resourceVersion = JsonUtil.getLong(json, "resource_version"); + obj.resourceVersion = JsonUtil.getLong(jsonObj, "resource_version"); - obj.updatedAt = JsonUtil.getTimestamp(json, "updated_at"); + obj.updatedAt = JsonUtil.getTimestamp(jsonObj, "updated_at"); - obj.channel = Channel.fromString(JsonUtil.getString(json, "channel")); + obj.channel = Channel.fromString(JsonUtil.getString(jsonObj, "channel")); - obj.businessEntityId = JsonUtil.getString(json, "business_entity_id"); + obj.businessEntityId = JsonUtil.getString(jsonObj, "business_entity_id"); - obj.deleted = JsonUtil.getBoolean(json, "deleted"); + obj.deleted = JsonUtil.getBoolean(jsonObj, "deleted"); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/attachedItem/responses/AttachedItemCreateResponse.java b/src/main/java/com/chargebee/v4/models/attachedItem/responses/AttachedItemCreateResponse.java index 768ec955..a0ceaf20 100644 --- a/src/main/java/com/chargebee/v4/models/attachedItem/responses/AttachedItemCreateResponse.java +++ b/src/main/java/com/chargebee/v4/models/attachedItem/responses/AttachedItemCreateResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static AttachedItemCreateResponse fromJson(String json) { /** Parse JSON response into AttachedItemCreateResponse object with HTTP response. */ public static AttachedItemCreateResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __attachedItemJson = JsonUtil.getObject(json, "attached_item"); - if (__attachedItemJson != null) { - builder.attachedItem(AttachedItem.fromJson(__attachedItemJson)); + JsonObject __attachedItemObj = JsonUtil.getJsonObject(jsonObj, "attached_item"); + if (__attachedItemObj != null) { + builder.attachedItem(AttachedItem.fromJson(__attachedItemObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/attachedItem/responses/AttachedItemDeleteResponse.java b/src/main/java/com/chargebee/v4/models/attachedItem/responses/AttachedItemDeleteResponse.java index 260d1c41..455d4388 100644 --- a/src/main/java/com/chargebee/v4/models/attachedItem/responses/AttachedItemDeleteResponse.java +++ b/src/main/java/com/chargebee/v4/models/attachedItem/responses/AttachedItemDeleteResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static AttachedItemDeleteResponse fromJson(String json) { /** Parse JSON response into AttachedItemDeleteResponse object with HTTP response. */ public static AttachedItemDeleteResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __attachedItemJson = JsonUtil.getObject(json, "attached_item"); - if (__attachedItemJson != null) { - builder.attachedItem(AttachedItem.fromJson(__attachedItemJson)); + JsonObject __attachedItemObj = JsonUtil.getJsonObject(jsonObj, "attached_item"); + if (__attachedItemObj != null) { + builder.attachedItem(AttachedItem.fromJson(__attachedItemObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/attachedItem/responses/AttachedItemListResponse.java b/src/main/java/com/chargebee/v4/models/attachedItem/responses/AttachedItemListResponse.java index 02a523fc..5629df8e 100644 --- a/src/main/java/com/chargebee/v4/models/attachedItem/responses/AttachedItemListResponse.java +++ b/src/main/java/com/chargebee/v4/models/attachedItem/responses/AttachedItemListResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.exceptions.ChargebeeException; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; import com.chargebee.v4.services.AttachedItemService; import com.chargebee.v4.models.attachedItem.params.AttachedItemListParams; @@ -48,13 +49,12 @@ private AttachedItemListResponse( */ public static AttachedItemListResponse fromJson(String json) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(AttachedItemListItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "list"), AttachedItemListItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new AttachedItemListResponse(list, nextOffset, null, null, null, null); } catch (Exception e) { @@ -73,13 +73,12 @@ public static AttachedItemListResponse fromJson( String itemId, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(AttachedItemListItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "list"), AttachedItemListItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new AttachedItemListResponse( list, nextOffset, itemId, service, originalParams, httpResponse); @@ -180,11 +179,15 @@ public AttachedItem getAttachedItem() { } public static AttachedItemListItem fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static AttachedItemListItem fromJson(JsonObject jsonObj) { AttachedItemListItem item = new AttachedItemListItem(); - String __attachedItemJson = JsonUtil.getObject(json, "attached_item"); - if (__attachedItemJson != null) { - item.attachedItem = AttachedItem.fromJson(__attachedItemJson); + JsonObject __attachedItemObj = JsonUtil.getJsonObject(jsonObj, "attached_item"); + if (__attachedItemObj != null) { + item.attachedItem = AttachedItem.fromJson(__attachedItemObj); } return item; diff --git a/src/main/java/com/chargebee/v4/models/attachedItem/responses/AttachedItemRetrieveResponse.java b/src/main/java/com/chargebee/v4/models/attachedItem/responses/AttachedItemRetrieveResponse.java index 149546cc..493b3413 100644 --- a/src/main/java/com/chargebee/v4/models/attachedItem/responses/AttachedItemRetrieveResponse.java +++ b/src/main/java/com/chargebee/v4/models/attachedItem/responses/AttachedItemRetrieveResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static AttachedItemRetrieveResponse fromJson(String json) { /** Parse JSON response into AttachedItemRetrieveResponse object with HTTP response. */ public static AttachedItemRetrieveResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __attachedItemJson = JsonUtil.getObject(json, "attached_item"); - if (__attachedItemJson != null) { - builder.attachedItem(AttachedItem.fromJson(__attachedItemJson)); + JsonObject __attachedItemObj = JsonUtil.getJsonObject(jsonObj, "attached_item"); + if (__attachedItemObj != null) { + builder.attachedItem(AttachedItem.fromJson(__attachedItemObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/attachedItem/responses/AttachedItemUpdateResponse.java b/src/main/java/com/chargebee/v4/models/attachedItem/responses/AttachedItemUpdateResponse.java index 67182139..4c6927ad 100644 --- a/src/main/java/com/chargebee/v4/models/attachedItem/responses/AttachedItemUpdateResponse.java +++ b/src/main/java/com/chargebee/v4/models/attachedItem/responses/AttachedItemUpdateResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static AttachedItemUpdateResponse fromJson(String json) { /** Parse JSON response into AttachedItemUpdateResponse object with HTTP response. */ public static AttachedItemUpdateResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __attachedItemJson = JsonUtil.getObject(json, "attached_item"); - if (__attachedItemJson != null) { - builder.attachedItem(AttachedItem.fromJson(__attachedItemJson)); + JsonObject __attachedItemObj = JsonUtil.getJsonObject(jsonObj, "attached_item"); + if (__attachedItemObj != null) { + builder.attachedItem(AttachedItem.fromJson(__attachedItemObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/attribute/Attribute.java b/src/main/java/com/chargebee/v4/models/attribute/Attribute.java index 394a3330..24ace54b 100644 --- a/src/main/java/com/chargebee/v4/models/attribute/Attribute.java +++ b/src/main/java/com/chargebee/v4/models/attribute/Attribute.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.attribute; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; public class Attribute { @@ -23,11 +24,15 @@ public String getValue() { } public static Attribute fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Attribute fromJson(JsonObject jsonObj) { Attribute obj = new Attribute(); - obj.name = JsonUtil.getString(json, "name"); + obj.name = JsonUtil.getString(jsonObj, "name"); - obj.value = JsonUtil.getString(json, "value"); + obj.value = JsonUtil.getString(jsonObj, "value"); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/billingConfiguration/BillingConfiguration.java b/src/main/java/com/chargebee/v4/models/billingConfiguration/BillingConfiguration.java index c66c2c68..8a55ca5e 100644 --- a/src/main/java/com/chargebee/v4/models/billingConfiguration/BillingConfiguration.java +++ b/src/main/java/com/chargebee/v4/models/billingConfiguration/BillingConfiguration.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.billingConfiguration; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import java.sql.Timestamp; import java.util.List; @@ -25,14 +26,16 @@ public List getBillingDates() { } public static BillingConfiguration fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static BillingConfiguration fromJson(JsonObject jsonObj) { BillingConfiguration obj = new BillingConfiguration(); - obj.isCalendarBillingEnabled = JsonUtil.getBoolean(json, "is_calendar_billing_enabled"); + obj.isCalendarBillingEnabled = JsonUtil.getBoolean(jsonObj, "is_calendar_billing_enabled"); obj.billingDates = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "billing_dates")).stream() - .map(BillingDates::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "billing_dates"), BillingDates::fromJson); return obj; } @@ -77,11 +80,15 @@ public Timestamp getEndDate() { } public static BillingDates fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static BillingDates fromJson(JsonObject jsonObj) { BillingDates obj = new BillingDates(); - obj.startDate = JsonUtil.getTimestamp(json, "start_date"); + obj.startDate = JsonUtil.getTimestamp(jsonObj, "start_date"); - obj.endDate = JsonUtil.getTimestamp(json, "end_date"); + obj.endDate = JsonUtil.getTimestamp(jsonObj, "end_date"); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/brand/Brand.java b/src/main/java/com/chargebee/v4/models/brand/Brand.java index 6f14d48e..6b0a27ee 100644 --- a/src/main/java/com/chargebee/v4/models/brand/Brand.java +++ b/src/main/java/com/chargebee/v4/models/brand/Brand.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.brand; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; public class Brand { @@ -23,11 +24,15 @@ public String getName() { } public static Brand fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Brand fromJson(JsonObject jsonObj) { Brand obj = new Brand(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.name = JsonUtil.getString(json, "name"); + obj.name = JsonUtil.getString(jsonObj, "name"); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/brandConfiguration/responses/BrandConfigurationRetrieveResponse.java b/src/main/java/com/chargebee/v4/models/brandConfiguration/responses/BrandConfigurationRetrieveResponse.java index 2610f9df..bb8c023d 100644 --- a/src/main/java/com/chargebee/v4/models/brandConfiguration/responses/BrandConfigurationRetrieveResponse.java +++ b/src/main/java/com/chargebee/v4/models/brandConfiguration/responses/BrandConfigurationRetrieveResponse.java @@ -2,6 +2,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -25,9 +26,10 @@ public static BrandConfigurationRetrieveResponse fromJson(String json) { /** Parse JSON response into BrandConfigurationRetrieveResponse object with HTTP response. */ public static BrandConfigurationRetrieveResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - builder.brandConfiguration(JsonUtil.getObject(json, "brand_configuration")); + builder.brandConfiguration(JsonUtil.getObject(jsonObj, "brand_configuration")); builder.httpResponse(httpResponse); return builder.build(); diff --git a/src/main/java/com/chargebee/v4/models/businessEntity/BusinessEntity.java b/src/main/java/com/chargebee/v4/models/businessEntity/BusinessEntity.java index 91338377..c29442c4 100644 --- a/src/main/java/com/chargebee/v4/models/businessEntity/BusinessEntity.java +++ b/src/main/java/com/chargebee/v4/models/businessEntity/BusinessEntity.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.businessEntity; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import java.sql.Timestamp; public class BusinessEntity { @@ -77,21 +78,25 @@ public static Status fromString(String value) { } public static BusinessEntity fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static BusinessEntity fromJson(JsonObject jsonObj) { BusinessEntity obj = new BusinessEntity(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.name = JsonUtil.getString(json, "name"); + obj.name = JsonUtil.getString(jsonObj, "name"); - obj.status = Status.fromString(JsonUtil.getString(json, "status")); + obj.status = Status.fromString(JsonUtil.getString(jsonObj, "status")); - obj.deleted = JsonUtil.getBoolean(json, "deleted"); + obj.deleted = JsonUtil.getBoolean(jsonObj, "deleted"); - obj.createdAt = JsonUtil.getTimestamp(json, "created_at"); + obj.createdAt = JsonUtil.getTimestamp(jsonObj, "created_at"); - obj.resourceVersion = JsonUtil.getLong(json, "resource_version"); + obj.resourceVersion = JsonUtil.getLong(jsonObj, "resource_version"); - obj.updatedAt = JsonUtil.getTimestamp(json, "updated_at"); + obj.updatedAt = JsonUtil.getTimestamp(jsonObj, "updated_at"); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/businessEntity/responses/BusinessEntityCreateTransfersResponse.java b/src/main/java/com/chargebee/v4/models/businessEntity/responses/BusinessEntityCreateTransfersResponse.java index 88bb5574..2c7cd4d7 100644 --- a/src/main/java/com/chargebee/v4/models/businessEntity/responses/BusinessEntityCreateTransfersResponse.java +++ b/src/main/java/com/chargebee/v4/models/businessEntity/responses/BusinessEntityCreateTransfersResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,12 +28,14 @@ public static BusinessEntityCreateTransfersResponse fromJson(String json) { /** Parse JSON response into BusinessEntityCreateTransfersResponse object with HTTP response. */ public static BusinessEntityCreateTransfersResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __businessEntityTransferJson = JsonUtil.getObject(json, "business_entity_transfer"); - if (__businessEntityTransferJson != null) { + JsonObject __businessEntityTransferObj = + JsonUtil.getJsonObject(jsonObj, "business_entity_transfer"); + if (__businessEntityTransferObj != null) { builder.businessEntityTransfer( - BusinessEntityTransfer.fromJson(__businessEntityTransferJson)); + BusinessEntityTransfer.fromJson(__businessEntityTransferObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/businessEntity/responses/BusinessEntityGetTransfersResponse.java b/src/main/java/com/chargebee/v4/models/businessEntity/responses/BusinessEntityGetTransfersResponse.java index b751bf97..3730c315 100644 --- a/src/main/java/com/chargebee/v4/models/businessEntity/responses/BusinessEntityGetTransfersResponse.java +++ b/src/main/java/com/chargebee/v4/models/businessEntity/responses/BusinessEntityGetTransfersResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.exceptions.ChargebeeException; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; import com.chargebee.v4.services.BusinessEntityService; import com.chargebee.v4.models.businessEntity.params.BusinessEntityGetTransfersParams; @@ -45,13 +46,13 @@ private BusinessEntityGetTransfersResponse( */ public static BusinessEntityGetTransfersResponse fromJson(String json) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(BusinessEntityGetTransfersItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "list"), BusinessEntityGetTransfersItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new BusinessEntityGetTransfersResponse(list, nextOffset, null, null, null); } catch (Exception e) { @@ -69,13 +70,13 @@ public static BusinessEntityGetTransfersResponse fromJson( BusinessEntityGetTransfersParams originalParams, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(BusinessEntityGetTransfersItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "list"), BusinessEntityGetTransfersItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new BusinessEntityGetTransfersResponse( list, nextOffset, service, originalParams, httpResponse); @@ -183,11 +184,16 @@ public BusinessEntityTransfer getBusinessEntityTransfer() { } public static BusinessEntityGetTransfersItem fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static BusinessEntityGetTransfersItem fromJson(JsonObject jsonObj) { BusinessEntityGetTransfersItem item = new BusinessEntityGetTransfersItem(); - String __businessEntityTransferJson = JsonUtil.getObject(json, "business_entity_transfer"); - if (__businessEntityTransferJson != null) { - item.businessEntityTransfer = BusinessEntityTransfer.fromJson(__businessEntityTransferJson); + JsonObject __businessEntityTransferObj = + JsonUtil.getJsonObject(jsonObj, "business_entity_transfer"); + if (__businessEntityTransferObj != null) { + item.businessEntityTransfer = BusinessEntityTransfer.fromJson(__businessEntityTransferObj); } return item; diff --git a/src/main/java/com/chargebee/v4/models/businessEntityTransfer/BusinessEntityTransfer.java b/src/main/java/com/chargebee/v4/models/businessEntityTransfer/BusinessEntityTransfer.java index 5665172a..829f2947 100644 --- a/src/main/java/com/chargebee/v4/models/businessEntityTransfer/BusinessEntityTransfer.java +++ b/src/main/java/com/chargebee/v4/models/businessEntityTransfer/BusinessEntityTransfer.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.businessEntityTransfer; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import java.sql.Timestamp; public class BusinessEntityTransfer { @@ -108,23 +109,27 @@ public static ReasonCode fromString(String value) { } public static BusinessEntityTransfer fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static BusinessEntityTransfer fromJson(JsonObject jsonObj) { BusinessEntityTransfer obj = new BusinessEntityTransfer(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.resourceType = ResourceType.fromString(JsonUtil.getString(json, "resource_type")); + obj.resourceType = ResourceType.fromString(JsonUtil.getString(jsonObj, "resource_type")); - obj.resourceId = JsonUtil.getString(json, "resource_id"); + obj.resourceId = JsonUtil.getString(jsonObj, "resource_id"); - obj.activeResourceId = JsonUtil.getString(json, "active_resource_id"); + obj.activeResourceId = JsonUtil.getString(jsonObj, "active_resource_id"); - obj.destinationBusinessEntityId = JsonUtil.getString(json, "destination_business_entity_id"); + obj.destinationBusinessEntityId = JsonUtil.getString(jsonObj, "destination_business_entity_id"); - obj.sourceBusinessEntityId = JsonUtil.getString(json, "source_business_entity_id"); + obj.sourceBusinessEntityId = JsonUtil.getString(jsonObj, "source_business_entity_id"); - obj.reasonCode = ReasonCode.fromString(JsonUtil.getString(json, "reason_code")); + obj.reasonCode = ReasonCode.fromString(JsonUtil.getString(jsonObj, "reason_code")); - obj.createdAt = JsonUtil.getTimestamp(json, "created_at"); + obj.createdAt = JsonUtil.getTimestamp(jsonObj, "created_at"); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/businessProfile/responses/BusinessProfileRetrieveResponse.java b/src/main/java/com/chargebee/v4/models/businessProfile/responses/BusinessProfileRetrieveResponse.java index 4d3744a8..374ac071 100644 --- a/src/main/java/com/chargebee/v4/models/businessProfile/responses/BusinessProfileRetrieveResponse.java +++ b/src/main/java/com/chargebee/v4/models/businessProfile/responses/BusinessProfileRetrieveResponse.java @@ -2,6 +2,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -25,9 +26,10 @@ public static BusinessProfileRetrieveResponse fromJson(String json) { /** Parse JSON response into BusinessProfileRetrieveResponse object with HTTP response. */ public static BusinessProfileRetrieveResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - builder.businessProfile(JsonUtil.getObject(json, "business_profile")); + builder.businessProfile(JsonUtil.getObject(jsonObj, "business_profile")); builder.httpResponse(httpResponse); return builder.build(); diff --git a/src/main/java/com/chargebee/v4/models/card/Card.java b/src/main/java/com/chargebee/v4/models/card/Card.java index 166bc545..6ab493f6 100644 --- a/src/main/java/com/chargebee/v4/models/card/Card.java +++ b/src/main/java/com/chargebee/v4/models/card/Card.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.card; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import java.sql.Timestamp; public class Card { @@ -468,63 +469,67 @@ public static PoweredBy fromString(String value) { } public static Card fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Card fromJson(JsonObject jsonObj) { Card obj = new Card(); - obj.paymentSourceId = JsonUtil.getString(json, "payment_source_id"); + obj.paymentSourceId = JsonUtil.getString(jsonObj, "payment_source_id"); - obj.status = Status.fromString(JsonUtil.getString(json, "status")); + obj.status = Status.fromString(JsonUtil.getString(jsonObj, "status")); - obj.gateway = Gateway.fromString(JsonUtil.getString(json, "gateway")); + obj.gateway = Gateway.fromString(JsonUtil.getString(jsonObj, "gateway")); - obj.gatewayAccountId = JsonUtil.getString(json, "gateway_account_id"); + obj.gatewayAccountId = JsonUtil.getString(jsonObj, "gateway_account_id"); - obj.refTxId = JsonUtil.getString(json, "ref_tx_id"); + obj.refTxId = JsonUtil.getString(jsonObj, "ref_tx_id"); - obj.firstName = JsonUtil.getString(json, "first_name"); + obj.firstName = JsonUtil.getString(jsonObj, "first_name"); - obj.lastName = JsonUtil.getString(json, "last_name"); + obj.lastName = JsonUtil.getString(jsonObj, "last_name"); - obj.iin = JsonUtil.getString(json, "iin"); + obj.iin = JsonUtil.getString(jsonObj, "iin"); - obj.last4 = JsonUtil.getString(json, "last4"); + obj.last4 = JsonUtil.getString(jsonObj, "last4"); - obj.cardType = CardType.fromString(JsonUtil.getString(json, "card_type")); + obj.cardType = CardType.fromString(JsonUtil.getString(jsonObj, "card_type")); - obj.fundingType = FundingType.fromString(JsonUtil.getString(json, "funding_type")); + obj.fundingType = FundingType.fromString(JsonUtil.getString(jsonObj, "funding_type")); - obj.expiryMonth = JsonUtil.getInteger(json, "expiry_month"); + obj.expiryMonth = JsonUtil.getInteger(jsonObj, "expiry_month"); - obj.expiryYear = JsonUtil.getInteger(json, "expiry_year"); + obj.expiryYear = JsonUtil.getInteger(jsonObj, "expiry_year"); - obj.issuingCountry = JsonUtil.getString(json, "issuing_country"); + obj.issuingCountry = JsonUtil.getString(jsonObj, "issuing_country"); - obj.billingAddr1 = JsonUtil.getString(json, "billing_addr1"); + obj.billingAddr1 = JsonUtil.getString(jsonObj, "billing_addr1"); - obj.billingAddr2 = JsonUtil.getString(json, "billing_addr2"); + obj.billingAddr2 = JsonUtil.getString(jsonObj, "billing_addr2"); - obj.billingCity = JsonUtil.getString(json, "billing_city"); + obj.billingCity = JsonUtil.getString(jsonObj, "billing_city"); - obj.billingStateCode = JsonUtil.getString(json, "billing_state_code"); + obj.billingStateCode = JsonUtil.getString(jsonObj, "billing_state_code"); - obj.billingState = JsonUtil.getString(json, "billing_state"); + obj.billingState = JsonUtil.getString(jsonObj, "billing_state"); - obj.billingCountry = JsonUtil.getString(json, "billing_country"); + obj.billingCountry = JsonUtil.getString(jsonObj, "billing_country"); - obj.billingZip = JsonUtil.getString(json, "billing_zip"); + obj.billingZip = JsonUtil.getString(jsonObj, "billing_zip"); - obj.createdAt = JsonUtil.getTimestamp(json, "created_at"); + obj.createdAt = JsonUtil.getTimestamp(jsonObj, "created_at"); - obj.resourceVersion = JsonUtil.getLong(json, "resource_version"); + obj.resourceVersion = JsonUtil.getLong(jsonObj, "resource_version"); - obj.updatedAt = JsonUtil.getTimestamp(json, "updated_at"); + obj.updatedAt = JsonUtil.getTimestamp(jsonObj, "updated_at"); - obj.ipAddress = JsonUtil.getString(json, "ip_address"); + obj.ipAddress = JsonUtil.getString(jsonObj, "ip_address"); - obj.poweredBy = PoweredBy.fromString(JsonUtil.getString(json, "powered_by")); + obj.poweredBy = PoweredBy.fromString(JsonUtil.getString(jsonObj, "powered_by")); - obj.customerId = JsonUtil.getString(json, "customer_id"); + obj.customerId = JsonUtil.getString(jsonObj, "customer_id"); - obj.maskedNumber = JsonUtil.getString(json, "masked_number"); + obj.maskedNumber = JsonUtil.getString(jsonObj, "masked_number"); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/card/responses/CardRetrieveResponse.java b/src/main/java/com/chargebee/v4/models/card/responses/CardRetrieveResponse.java index 9f9ec27b..0a49811d 100644 --- a/src/main/java/com/chargebee/v4/models/card/responses/CardRetrieveResponse.java +++ b/src/main/java/com/chargebee/v4/models/card/responses/CardRetrieveResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static CardRetrieveResponse fromJson(String json) { /** Parse JSON response into CardRetrieveResponse object with HTTP response. */ public static CardRetrieveResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __cardJson = JsonUtil.getObject(json, "card"); - if (__cardJson != null) { - builder.card(Card.fromJson(__cardJson)); + JsonObject __cardObj = JsonUtil.getJsonObject(jsonObj, "card"); + if (__cardObj != null) { + builder.card(Card.fromJson(__cardObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/card/responses/CardSwitchGatewayForCustomerResponse.java b/src/main/java/com/chargebee/v4/models/card/responses/CardSwitchGatewayForCustomerResponse.java index b457ba33..79dbcffa 100644 --- a/src/main/java/com/chargebee/v4/models/card/responses/CardSwitchGatewayForCustomerResponse.java +++ b/src/main/java/com/chargebee/v4/models/card/responses/CardSwitchGatewayForCustomerResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -33,16 +34,17 @@ public static CardSwitchGatewayForCustomerResponse fromJson(String json) { /** Parse JSON response into CardSwitchGatewayForCustomerResponse object with HTTP response. */ public static CardSwitchGatewayForCustomerResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - builder.customer(Customer.fromJson(__customerJson)); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + builder.customer(Customer.fromJson(__customerObj)); } - String __cardJson = JsonUtil.getObject(json, "card"); - if (__cardJson != null) { - builder.card(Card.fromJson(__cardJson)); + JsonObject __cardObj = JsonUtil.getJsonObject(jsonObj, "card"); + if (__cardObj != null) { + builder.card(Card.fromJson(__cardObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/card/responses/CopyCardForCustomerResponse.java b/src/main/java/com/chargebee/v4/models/card/responses/CopyCardForCustomerResponse.java index a01c7d10..490888bb 100644 --- a/src/main/java/com/chargebee/v4/models/card/responses/CopyCardForCustomerResponse.java +++ b/src/main/java/com/chargebee/v4/models/card/responses/CopyCardForCustomerResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,12 +28,14 @@ public static CopyCardForCustomerResponse fromJson(String json) { /** Parse JSON response into CopyCardForCustomerResponse object with HTTP response. */ public static CopyCardForCustomerResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __thirdPartyPaymentMethodJson = JsonUtil.getObject(json, "third_party_payment_method"); - if (__thirdPartyPaymentMethodJson != null) { + JsonObject __thirdPartyPaymentMethodObj = + JsonUtil.getJsonObject(jsonObj, "third_party_payment_method"); + if (__thirdPartyPaymentMethodObj != null) { builder.thirdPartyPaymentMethod( - ThirdPartyPaymentMethod.fromJson(__thirdPartyPaymentMethodJson)); + ThirdPartyPaymentMethod.fromJson(__thirdPartyPaymentMethodObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/card/responses/DeleteCardForCustomerResponse.java b/src/main/java/com/chargebee/v4/models/card/responses/DeleteCardForCustomerResponse.java index af97ddb1..60a89308 100644 --- a/src/main/java/com/chargebee/v4/models/card/responses/DeleteCardForCustomerResponse.java +++ b/src/main/java/com/chargebee/v4/models/card/responses/DeleteCardForCustomerResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static DeleteCardForCustomerResponse fromJson(String json) { /** Parse JSON response into DeleteCardForCustomerResponse object with HTTP response. */ public static DeleteCardForCustomerResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - builder.customer(Customer.fromJson(__customerJson)); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + builder.customer(Customer.fromJson(__customerObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/card/responses/UpdateCardForCustomerResponse.java b/src/main/java/com/chargebee/v4/models/card/responses/UpdateCardForCustomerResponse.java index 6736fc99..b555770b 100644 --- a/src/main/java/com/chargebee/v4/models/card/responses/UpdateCardForCustomerResponse.java +++ b/src/main/java/com/chargebee/v4/models/card/responses/UpdateCardForCustomerResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -33,16 +34,17 @@ public static UpdateCardForCustomerResponse fromJson(String json) { /** Parse JSON response into UpdateCardForCustomerResponse object with HTTP response. */ public static UpdateCardForCustomerResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - builder.customer(Customer.fromJson(__customerJson)); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + builder.customer(Customer.fromJson(__customerObj)); } - String __cardJson = JsonUtil.getObject(json, "card"); - if (__cardJson != null) { - builder.card(Card.fromJson(__cardJson)); + JsonObject __cardObj = JsonUtil.getJsonObject(jsonObj, "card"); + if (__cardObj != null) { + builder.card(Card.fromJson(__cardObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/comment/Comment.java b/src/main/java/com/chargebee/v4/models/comment/Comment.java index f0156d1c..49f9cec6 100644 --- a/src/main/java/com/chargebee/v4/models/comment/Comment.java +++ b/src/main/java/com/chargebee/v4/models/comment/Comment.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.comment; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import java.sql.Timestamp; public class Comment { @@ -136,23 +137,27 @@ public static Type fromString(String value) { } public static Comment fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Comment fromJson(JsonObject jsonObj) { Comment obj = new Comment(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.entityType = EntityType.fromString(JsonUtil.getString(json, "entity_type")); + obj.entityType = EntityType.fromString(JsonUtil.getString(jsonObj, "entity_type")); - obj.addedBy = JsonUtil.getString(json, "added_by"); + obj.addedBy = JsonUtil.getString(jsonObj, "added_by"); - obj.notes = JsonUtil.getString(json, "notes"); + obj.notes = JsonUtil.getString(jsonObj, "notes"); - obj.createdAt = JsonUtil.getTimestamp(json, "created_at"); + obj.createdAt = JsonUtil.getTimestamp(jsonObj, "created_at"); - obj.type = Type.fromString(JsonUtil.getString(json, "type")); + obj.type = Type.fromString(JsonUtil.getString(jsonObj, "type")); - obj.entityId = JsonUtil.getString(json, "entity_id"); + obj.entityId = JsonUtil.getString(jsonObj, "entity_id"); - obj.businessEntityId = JsonUtil.getString(json, "business_entity_id"); + obj.businessEntityId = JsonUtil.getString(jsonObj, "business_entity_id"); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/comment/responses/CommentCreateResponse.java b/src/main/java/com/chargebee/v4/models/comment/responses/CommentCreateResponse.java index c21ae14a..1a0f4105 100644 --- a/src/main/java/com/chargebee/v4/models/comment/responses/CommentCreateResponse.java +++ b/src/main/java/com/chargebee/v4/models/comment/responses/CommentCreateResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -26,11 +27,12 @@ public static CommentCreateResponse fromJson(String json) { /** Parse JSON response into CommentCreateResponse object with HTTP response. */ public static CommentCreateResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __commentJson = JsonUtil.getObject(json, "comment"); - if (__commentJson != null) { - builder.comment(Comment.fromJson(__commentJson)); + JsonObject __commentObj = JsonUtil.getJsonObject(jsonObj, "comment"); + if (__commentObj != null) { + builder.comment(Comment.fromJson(__commentObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/comment/responses/CommentDeleteResponse.java b/src/main/java/com/chargebee/v4/models/comment/responses/CommentDeleteResponse.java index f9294ce6..2e5fe83d 100644 --- a/src/main/java/com/chargebee/v4/models/comment/responses/CommentDeleteResponse.java +++ b/src/main/java/com/chargebee/v4/models/comment/responses/CommentDeleteResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -26,11 +27,12 @@ public static CommentDeleteResponse fromJson(String json) { /** Parse JSON response into CommentDeleteResponse object with HTTP response. */ public static CommentDeleteResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __commentJson = JsonUtil.getObject(json, "comment"); - if (__commentJson != null) { - builder.comment(Comment.fromJson(__commentJson)); + JsonObject __commentObj = JsonUtil.getJsonObject(jsonObj, "comment"); + if (__commentObj != null) { + builder.comment(Comment.fromJson(__commentObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/comment/responses/CommentListResponse.java b/src/main/java/com/chargebee/v4/models/comment/responses/CommentListResponse.java index 6ae13bfc..49fae386 100644 --- a/src/main/java/com/chargebee/v4/models/comment/responses/CommentListResponse.java +++ b/src/main/java/com/chargebee/v4/models/comment/responses/CommentListResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.exceptions.ChargebeeException; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; import com.chargebee.v4.services.CommentService; import com.chargebee.v4.models.comment.params.CommentListParams; @@ -43,13 +44,12 @@ private CommentListResponse( */ public static CommentListResponse fromJson(String json) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(CommentListItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "list"), CommentListItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new CommentListResponse(list, nextOffset, null, null, null); } catch (Exception e) { @@ -67,13 +67,12 @@ public static CommentListResponse fromJson( CommentListParams originalParams, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(CommentListItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "list"), CommentListItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new CommentListResponse(list, nextOffset, service, originalParams, httpResponse); } catch (Exception e) { @@ -173,11 +172,15 @@ public Comment getComment() { } public static CommentListItem fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static CommentListItem fromJson(JsonObject jsonObj) { CommentListItem item = new CommentListItem(); - String __commentJson = JsonUtil.getObject(json, "comment"); - if (__commentJson != null) { - item.comment = Comment.fromJson(__commentJson); + JsonObject __commentObj = JsonUtil.getJsonObject(jsonObj, "comment"); + if (__commentObj != null) { + item.comment = Comment.fromJson(__commentObj); } return item; diff --git a/src/main/java/com/chargebee/v4/models/comment/responses/CommentRetrieveResponse.java b/src/main/java/com/chargebee/v4/models/comment/responses/CommentRetrieveResponse.java index e6390262..08dae091 100644 --- a/src/main/java/com/chargebee/v4/models/comment/responses/CommentRetrieveResponse.java +++ b/src/main/java/com/chargebee/v4/models/comment/responses/CommentRetrieveResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static CommentRetrieveResponse fromJson(String json) { /** Parse JSON response into CommentRetrieveResponse object with HTTP response. */ public static CommentRetrieveResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __commentJson = JsonUtil.getObject(json, "comment"); - if (__commentJson != null) { - builder.comment(Comment.fromJson(__commentJson)); + JsonObject __commentObj = JsonUtil.getJsonObject(jsonObj, "comment"); + if (__commentObj != null) { + builder.comment(Comment.fromJson(__commentObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/configuration/Configuration.java b/src/main/java/com/chargebee/v4/models/configuration/Configuration.java index 25d8f5b9..8a5bf449 100644 --- a/src/main/java/com/chargebee/v4/models/configuration/Configuration.java +++ b/src/main/java/com/chargebee/v4/models/configuration/Configuration.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.configuration; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; public class Configuration { @@ -91,16 +92,20 @@ public static ChargebeeResponseSchemaType fromString(String value) { } public static Configuration fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Configuration fromJson(JsonObject jsonObj) { Configuration obj = new Configuration(); - obj.domain = JsonUtil.getString(json, "domain"); + obj.domain = JsonUtil.getString(jsonObj, "domain"); obj.productCatalogVersion = - ProductCatalogVersion.fromString(JsonUtil.getString(json, "product_catalog_version")); + ProductCatalogVersion.fromString(JsonUtil.getString(jsonObj, "product_catalog_version")); obj.chargebeeResponseSchemaType = ChargebeeResponseSchemaType.fromString( - JsonUtil.getString(json, "chargebee_response_schema_type")); + JsonUtil.getString(jsonObj, "chargebee_response_schema_type")); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/configuration/responses/ConfigurationListResponse.java b/src/main/java/com/chargebee/v4/models/configuration/responses/ConfigurationListResponse.java index b83ac1e3..1898e9fb 100644 --- a/src/main/java/com/chargebee/v4/models/configuration/responses/ConfigurationListResponse.java +++ b/src/main/java/com/chargebee/v4/models/configuration/responses/ConfigurationListResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; import java.util.List; @@ -28,15 +29,12 @@ public static ConfigurationListResponse fromJson(String json) { /** Parse JSON response into ConfigurationListResponse object with HTTP response. */ public static ConfigurationListResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __configurationsJson = JsonUtil.getArray(json, "configurations"); - if (__configurationsJson != null) { - builder.configurations( - JsonUtil.parseObjectArray(__configurationsJson).stream() - .map(Configuration::fromJson) - .collect(java.util.stream.Collectors.toList())); - } + builder.configurations( + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "configurations"), Configuration::fromJson)); builder.httpResponse(httpResponse); return builder.build(); diff --git a/src/main/java/com/chargebee/v4/models/contact/Contact.java b/src/main/java/com/chargebee/v4/models/contact/Contact.java index 8bc6d165..02ba2efd 100644 --- a/src/main/java/com/chargebee/v4/models/contact/Contact.java +++ b/src/main/java/com/chargebee/v4/models/contact/Contact.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.contact; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; public class Contact { @@ -58,25 +59,29 @@ public Boolean getSendBillingEmail() { } public static Contact fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Contact fromJson(JsonObject jsonObj) { Contact obj = new Contact(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.firstName = JsonUtil.getString(json, "first_name"); + obj.firstName = JsonUtil.getString(jsonObj, "first_name"); - obj.lastName = JsonUtil.getString(json, "last_name"); + obj.lastName = JsonUtil.getString(jsonObj, "last_name"); - obj.email = JsonUtil.getString(json, "email"); + obj.email = JsonUtil.getString(jsonObj, "email"); - obj.phone = JsonUtil.getString(json, "phone"); + obj.phone = JsonUtil.getString(jsonObj, "phone"); - obj.label = JsonUtil.getString(json, "label"); + obj.label = JsonUtil.getString(jsonObj, "label"); - obj.enabled = JsonUtil.getBoolean(json, "enabled"); + obj.enabled = JsonUtil.getBoolean(jsonObj, "enabled"); - obj.sendAccountEmail = JsonUtil.getBoolean(json, "send_account_email"); + obj.sendAccountEmail = JsonUtil.getBoolean(jsonObj, "send_account_email"); - obj.sendBillingEmail = JsonUtil.getBoolean(json, "send_billing_email"); + obj.sendBillingEmail = JsonUtil.getBoolean(jsonObj, "send_billing_email"); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/contractTerm/ContractTerm.java b/src/main/java/com/chargebee/v4/models/contractTerm/ContractTerm.java index 37255587..1a52868a 100644 --- a/src/main/java/com/chargebee/v4/models/contractTerm/ContractTerm.java +++ b/src/main/java/com/chargebee/v4/models/contractTerm/ContractTerm.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.contractTerm; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import java.sql.Timestamp; public class ContractTerm { @@ -138,32 +139,36 @@ public static ActionAtTermEnd fromString(String value) { } public static ContractTerm fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static ContractTerm fromJson(JsonObject jsonObj) { ContractTerm obj = new ContractTerm(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.status = Status.fromString(JsonUtil.getString(json, "status")); + obj.status = Status.fromString(JsonUtil.getString(jsonObj, "status")); - obj.contractStart = JsonUtil.getTimestamp(json, "contract_start"); + obj.contractStart = JsonUtil.getTimestamp(jsonObj, "contract_start"); - obj.contractEnd = JsonUtil.getTimestamp(json, "contract_end"); + obj.contractEnd = JsonUtil.getTimestamp(jsonObj, "contract_end"); - obj.billingCycle = JsonUtil.getInteger(json, "billing_cycle"); + obj.billingCycle = JsonUtil.getInteger(jsonObj, "billing_cycle"); obj.actionAtTermEnd = - ActionAtTermEnd.fromString(JsonUtil.getString(json, "action_at_term_end")); + ActionAtTermEnd.fromString(JsonUtil.getString(jsonObj, "action_at_term_end")); - obj.totalContractValue = JsonUtil.getLong(json, "total_contract_value"); + obj.totalContractValue = JsonUtil.getLong(jsonObj, "total_contract_value"); - obj.totalContractValueBeforeTax = JsonUtil.getLong(json, "total_contract_value_before_tax"); + obj.totalContractValueBeforeTax = JsonUtil.getLong(jsonObj, "total_contract_value_before_tax"); - obj.cancellationCutoffPeriod = JsonUtil.getInteger(json, "cancellation_cutoff_period"); + obj.cancellationCutoffPeriod = JsonUtil.getInteger(jsonObj, "cancellation_cutoff_period"); - obj.createdAt = JsonUtil.getTimestamp(json, "created_at"); + obj.createdAt = JsonUtil.getTimestamp(jsonObj, "created_at"); - obj.subscriptionId = JsonUtil.getString(json, "subscription_id"); + obj.subscriptionId = JsonUtil.getString(jsonObj, "subscription_id"); - obj.remainingBillingCycles = JsonUtil.getInteger(json, "remaining_billing_cycles"); + obj.remainingBillingCycles = JsonUtil.getInteger(jsonObj, "remaining_billing_cycles"); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/coupon/Coupon.java b/src/main/java/com/chargebee/v4/models/coupon/Coupon.java index e16d376f..099174f5 100644 --- a/src/main/java/com/chargebee/v4/models/coupon/Coupon.java +++ b/src/main/java/com/chargebee/v4/models/coupon/Coupon.java @@ -8,6 +8,8 @@ package com.chargebee.v4.models.coupon; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonArray; +import com.google.gson.JsonObject; import java.sql.Timestamp; import java.util.List; @@ -463,9 +465,12 @@ public static PlanConstraint fromString(String value) { } public static Coupon fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Coupon fromJson(JsonObject jsonObj) { Coupon obj = new Coupon(); - // Parse JSON to extract all keys for custom field extraction java.util.Set knownFields = new java.util.HashSet<>(); knownFields.add("id"); @@ -536,123 +541,98 @@ public static Coupon fromJson(String json) { knownFields.add("addon_ids"); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.name = JsonUtil.getString(json, "name"); + obj.name = JsonUtil.getString(jsonObj, "name"); - obj.invoiceName = JsonUtil.getString(json, "invoice_name"); + obj.invoiceName = JsonUtil.getString(jsonObj, "invoice_name"); - obj.discountType = DiscountType.fromString(JsonUtil.getString(json, "discount_type")); + obj.discountType = DiscountType.fromString(JsonUtil.getString(jsonObj, "discount_type")); - obj.discountPercentage = JsonUtil.getDouble(json, "discount_percentage"); + obj.discountPercentage = JsonUtil.getDouble(jsonObj, "discount_percentage"); - obj.discountAmount = JsonUtil.getLong(json, "discount_amount"); + obj.discountAmount = JsonUtil.getLong(jsonObj, "discount_amount"); - obj.discountQuantity = JsonUtil.getInteger(json, "discount_quantity"); + obj.discountQuantity = JsonUtil.getInteger(jsonObj, "discount_quantity"); - obj.currencyCode = JsonUtil.getString(json, "currency_code"); + obj.currencyCode = JsonUtil.getString(jsonObj, "currency_code"); - obj.durationType = DurationType.fromString(JsonUtil.getString(json, "duration_type")); + obj.durationType = DurationType.fromString(JsonUtil.getString(jsonObj, "duration_type")); - obj.durationMonth = JsonUtil.getInteger(json, "duration_month"); + obj.durationMonth = JsonUtil.getInteger(jsonObj, "duration_month"); - obj.validFrom = JsonUtil.getTimestamp(json, "valid_from"); + obj.validFrom = JsonUtil.getTimestamp(jsonObj, "valid_from"); - obj.validTill = JsonUtil.getTimestamp(json, "valid_till"); + obj.validTill = JsonUtil.getTimestamp(jsonObj, "valid_till"); - obj.maxRedemptions = JsonUtil.getInteger(json, "max_redemptions"); + obj.maxRedemptions = JsonUtil.getInteger(jsonObj, "max_redemptions"); - obj.status = Status.fromString(JsonUtil.getString(json, "status")); + obj.status = Status.fromString(JsonUtil.getString(jsonObj, "status")); - obj.applyDiscountOn = ApplyDiscountOn.fromString(JsonUtil.getString(json, "apply_discount_on")); + obj.applyDiscountOn = + ApplyDiscountOn.fromString(JsonUtil.getString(jsonObj, "apply_discount_on")); - obj.applyOn = ApplyOn.fromString(JsonUtil.getString(json, "apply_on")); + obj.applyOn = ApplyOn.fromString(JsonUtil.getString(jsonObj, "apply_on")); - obj.createdAt = JsonUtil.getTimestamp(json, "created_at"); + obj.createdAt = JsonUtil.getTimestamp(jsonObj, "created_at"); - obj.archivedAt = JsonUtil.getTimestamp(json, "archived_at"); + obj.archivedAt = JsonUtil.getTimestamp(jsonObj, "archived_at"); - obj.resourceVersion = JsonUtil.getLong(json, "resource_version"); + obj.resourceVersion = JsonUtil.getLong(jsonObj, "resource_version"); - obj.updatedAt = JsonUtil.getTimestamp(json, "updated_at"); + obj.updatedAt = JsonUtil.getTimestamp(jsonObj, "updated_at"); - obj.period = JsonUtil.getInteger(json, "period"); + obj.period = JsonUtil.getInteger(jsonObj, "period"); - obj.periodUnit = PeriodUnit.fromString(JsonUtil.getString(json, "period_unit")); + obj.periodUnit = PeriodUnit.fromString(JsonUtil.getString(jsonObj, "period_unit")); - obj.redemptions = JsonUtil.getInteger(json, "redemptions"); + obj.redemptions = JsonUtil.getInteger(jsonObj, "redemptions"); - obj.invoiceNotes = JsonUtil.getString(json, "invoice_notes"); + obj.invoiceNotes = JsonUtil.getString(jsonObj, "invoice_notes"); - String __metaDataJson = JsonUtil.getObject(json, "meta_data"); + JsonObject __metaDataObj = JsonUtil.getJsonObject(jsonObj, "meta_data"); obj.metaData = - __metaDataJson != null - ? JsonUtil.parseJsonObjectToMap(__metaDataJson) + __metaDataObj != null + ? JsonUtil.parseJsonObjectToMap(__metaDataObj) : new java.util.HashMap<>(); - obj.deleted = JsonUtil.getBoolean(json, "deleted"); + obj.deleted = JsonUtil.getBoolean(jsonObj, "deleted"); obj.itemConstraints = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "item_constraints")).stream() - .map(ItemConstraints::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "item_constraints"), ItemConstraints::fromJson); obj.itemConstraintCriteria = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "item_constraint_criteria")).stream() - .map(ItemConstraintCriteria::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "item_constraint_criteria"), + ItemConstraintCriteria::fromJson); obj.couponConstraints = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "coupon_constraints")).stream() - .map(CouponConstraints::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "coupon_constraints"), CouponConstraints::fromJson); - obj.planIds = JsonUtil.parseArrayOfString(JsonUtil.getArray(json, "plan_ids")); + JsonArray __planIdsArr = JsonUtil.getJsonArray(jsonObj, "plan_ids"); + if (__planIdsArr != null) { + obj.planIds = JsonUtil.parseArrayOfString(__planIdsArr); + } - obj.addonConstraint = AddonConstraint.fromString(JsonUtil.getString(json, "addon_constraint")); + obj.addonConstraint = + AddonConstraint.fromString(JsonUtil.getString(jsonObj, "addon_constraint")); - obj.planConstraint = PlanConstraint.fromString(JsonUtil.getString(json, "plan_constraint")); + obj.planConstraint = PlanConstraint.fromString(JsonUtil.getString(jsonObj, "plan_constraint")); - obj.includedInMrr = JsonUtil.getBoolean(json, "included_in_mrr"); + obj.includedInMrr = JsonUtil.getBoolean(jsonObj, "included_in_mrr"); - obj.addonIds = JsonUtil.parseArrayOfString(JsonUtil.getArray(json, "addon_ids")); + JsonArray __addonIdsArr = JsonUtil.getJsonArray(jsonObj, "addon_ids"); + if (__addonIdsArr != null) { + obj.addonIds = JsonUtil.parseArrayOfString(__addonIdsArr); + } - // Extract custom fields (fields starting with cf_) - obj.customFields = extractCustomFields(json, knownFields); + obj.customFields = JsonUtil.extractCustomFields(jsonObj, knownFields); return obj; } - /** - * Helper method to extract custom fields from JSON. Custom fields are fields that start with - * "cf_" and are not in the known fields set. - * - * @param json JSON string to parse - * @param knownFields set of known field names - * @return map of custom fields - */ - private static java.util.Map extractCustomFields( - String json, java.util.Set knownFields) { - java.util.Map customFields = new java.util.HashMap<>(); - try { - // Parse the entire JSON as a map - java.util.Map allFields = JsonUtil.parseJsonObjectToMap(json); - if (allFields != null) { - for (java.util.Map.Entry entry : allFields.entrySet()) { - String key = entry.getKey(); - // Include fields that start with "cf_" and are not in knownFields - if (key != null && key.startsWith("cf_") && !knownFields.contains(key)) { - customFields.put( - key, entry.getValue() != null ? String.valueOf(entry.getValue()) : null); - } - } - } - } catch (Exception e) { - // If parsing fails, return empty map - } - return customFields; - } - @Override public String toString() { return "Coupon{" @@ -894,19 +874,18 @@ public static Constraint fromString(String value) { } public static ItemConstraints fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static ItemConstraints fromJson(JsonObject jsonObj) { ItemConstraints obj = new ItemConstraints(); - obj.itemType = ItemType.fromString(JsonUtil.getString(json, "item_type")); + obj.itemType = ItemType.fromString(JsonUtil.getString(jsonObj, "item_type")); - obj.constraint = Constraint.fromString(JsonUtil.getString(json, "constraint")); + obj.constraint = Constraint.fromString(JsonUtil.getString(jsonObj, "constraint")); - String __itemPriceIdsJson = JsonUtil.getArray(json, "item_price_ids"); obj.itemPriceIds = - __itemPriceIdsJson != null - ? JsonUtil.parseObjectArray(__itemPriceIdsJson).stream() - .map(JsonUtil::parseJsonObjectToMap) - .collect(java.util.stream.Collectors.toList()) - : null; + JsonUtil.mapArrayToObjects(JsonUtil.getJsonArray(jsonObj, "item_price_ids")); return obj; } @@ -995,33 +974,21 @@ public static ItemType fromString(String value) { } public static ItemConstraintCriteria fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static ItemConstraintCriteria fromJson(JsonObject jsonObj) { ItemConstraintCriteria obj = new ItemConstraintCriteria(); - obj.itemType = ItemType.fromString(JsonUtil.getString(json, "item_type")); + obj.itemType = ItemType.fromString(JsonUtil.getString(jsonObj, "item_type")); - String __currenciesJson = JsonUtil.getArray(json, "currencies"); - obj.currencies = - __currenciesJson != null - ? JsonUtil.parseObjectArray(__currenciesJson).stream() - .map(JsonUtil::parseJsonObjectToMap) - .collect(java.util.stream.Collectors.toList()) - : null; + obj.currencies = JsonUtil.mapArrayToObjects(JsonUtil.getJsonArray(jsonObj, "currencies")); - String __itemFamilyIdsJson = JsonUtil.getArray(json, "item_family_ids"); obj.itemFamilyIds = - __itemFamilyIdsJson != null - ? JsonUtil.parseObjectArray(__itemFamilyIdsJson).stream() - .map(JsonUtil::parseJsonObjectToMap) - .collect(java.util.stream.Collectors.toList()) - : null; + JsonUtil.mapArrayToObjects(JsonUtil.getJsonArray(jsonObj, "item_family_ids")); - String __itemPricePeriodsJson = JsonUtil.getArray(json, "item_price_periods"); obj.itemPricePeriods = - __itemPricePeriodsJson != null - ? JsonUtil.parseObjectArray(__itemPricePeriodsJson).stream() - .map(JsonUtil::parseJsonObjectToMap) - .collect(java.util.stream.Collectors.toList()) - : null; + JsonUtil.mapArrayToObjects(JsonUtil.getJsonArray(jsonObj, "item_price_periods")); return obj; } @@ -1136,13 +1103,17 @@ public static Type fromString(String value) { } public static CouponConstraints fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static CouponConstraints fromJson(JsonObject jsonObj) { CouponConstraints obj = new CouponConstraints(); - obj.entityType = EntityType.fromString(JsonUtil.getString(json, "entity_type")); + obj.entityType = EntityType.fromString(JsonUtil.getString(jsonObj, "entity_type")); - obj.type = Type.fromString(JsonUtil.getString(json, "type")); + obj.type = Type.fromString(JsonUtil.getString(jsonObj, "type")); - obj.value = JsonUtil.getString(json, "value"); + obj.value = JsonUtil.getString(jsonObj, "value"); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/coupon/responses/CouponCopyResponse.java b/src/main/java/com/chargebee/v4/models/coupon/responses/CouponCopyResponse.java index 0eee614a..fbe1e2de 100644 --- a/src/main/java/com/chargebee/v4/models/coupon/responses/CouponCopyResponse.java +++ b/src/main/java/com/chargebee/v4/models/coupon/responses/CouponCopyResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** Immutable response object for CouponCopy operation. Contains the response data from the API. */ @@ -24,11 +25,12 @@ public static CouponCopyResponse fromJson(String json) { /** Parse JSON response into CouponCopyResponse object with HTTP response. */ public static CouponCopyResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __couponJson = JsonUtil.getObject(json, "coupon"); - if (__couponJson != null) { - builder.coupon(Coupon.fromJson(__couponJson)); + JsonObject __couponObj = JsonUtil.getJsonObject(jsonObj, "coupon"); + if (__couponObj != null) { + builder.coupon(Coupon.fromJson(__couponObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/coupon/responses/CouponCreateForItemsResponse.java b/src/main/java/com/chargebee/v4/models/coupon/responses/CouponCreateForItemsResponse.java index bc8c9d34..9c3badb0 100644 --- a/src/main/java/com/chargebee/v4/models/coupon/responses/CouponCreateForItemsResponse.java +++ b/src/main/java/com/chargebee/v4/models/coupon/responses/CouponCreateForItemsResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static CouponCreateForItemsResponse fromJson(String json) { /** Parse JSON response into CouponCreateForItemsResponse object with HTTP response. */ public static CouponCreateForItemsResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __couponJson = JsonUtil.getObject(json, "coupon"); - if (__couponJson != null) { - builder.coupon(Coupon.fromJson(__couponJson)); + JsonObject __couponObj = JsonUtil.getJsonObject(jsonObj, "coupon"); + if (__couponObj != null) { + builder.coupon(Coupon.fromJson(__couponObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/coupon/responses/CouponCreateResponse.java b/src/main/java/com/chargebee/v4/models/coupon/responses/CouponCreateResponse.java index e20e3c60..c15a5f67 100644 --- a/src/main/java/com/chargebee/v4/models/coupon/responses/CouponCreateResponse.java +++ b/src/main/java/com/chargebee/v4/models/coupon/responses/CouponCreateResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -26,11 +27,12 @@ public static CouponCreateResponse fromJson(String json) { /** Parse JSON response into CouponCreateResponse object with HTTP response. */ public static CouponCreateResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __couponJson = JsonUtil.getObject(json, "coupon"); - if (__couponJson != null) { - builder.coupon(Coupon.fromJson(__couponJson)); + JsonObject __couponObj = JsonUtil.getJsonObject(jsonObj, "coupon"); + if (__couponObj != null) { + builder.coupon(Coupon.fromJson(__couponObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/coupon/responses/CouponDeleteResponse.java b/src/main/java/com/chargebee/v4/models/coupon/responses/CouponDeleteResponse.java index 40d114da..3f0633b9 100644 --- a/src/main/java/com/chargebee/v4/models/coupon/responses/CouponDeleteResponse.java +++ b/src/main/java/com/chargebee/v4/models/coupon/responses/CouponDeleteResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -26,11 +27,12 @@ public static CouponDeleteResponse fromJson(String json) { /** Parse JSON response into CouponDeleteResponse object with HTTP response. */ public static CouponDeleteResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __couponJson = JsonUtil.getObject(json, "coupon"); - if (__couponJson != null) { - builder.coupon(Coupon.fromJson(__couponJson)); + JsonObject __couponObj = JsonUtil.getJsonObject(jsonObj, "coupon"); + if (__couponObj != null) { + builder.coupon(Coupon.fromJson(__couponObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/coupon/responses/CouponListResponse.java b/src/main/java/com/chargebee/v4/models/coupon/responses/CouponListResponse.java index a3ae8beb..80cddd74 100644 --- a/src/main/java/com/chargebee/v4/models/coupon/responses/CouponListResponse.java +++ b/src/main/java/com/chargebee/v4/models/coupon/responses/CouponListResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.exceptions.ChargebeeException; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; import com.chargebee.v4.services.CouponService; import com.chargebee.v4.models.coupon.params.CouponListParams; @@ -43,13 +44,12 @@ private CouponListResponse( */ public static CouponListResponse fromJson(String json) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(CouponListItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "list"), CouponListItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new CouponListResponse(list, nextOffset, null, null, null); } catch (Exception e) { @@ -64,13 +64,12 @@ public static CouponListResponse fromJson(String json) { public static CouponListResponse fromJson( String json, CouponService service, CouponListParams originalParams, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(CouponListItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "list"), CouponListItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new CouponListResponse(list, nextOffset, service, originalParams, httpResponse); } catch (Exception e) { @@ -170,11 +169,15 @@ public Coupon getCoupon() { } public static CouponListItem fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static CouponListItem fromJson(JsonObject jsonObj) { CouponListItem item = new CouponListItem(); - String __couponJson = JsonUtil.getObject(json, "coupon"); - if (__couponJson != null) { - item.coupon = Coupon.fromJson(__couponJson); + JsonObject __couponObj = JsonUtil.getJsonObject(jsonObj, "coupon"); + if (__couponObj != null) { + item.coupon = Coupon.fromJson(__couponObj); } return item; diff --git a/src/main/java/com/chargebee/v4/models/coupon/responses/CouponRetrieveResponse.java b/src/main/java/com/chargebee/v4/models/coupon/responses/CouponRetrieveResponse.java index 44ad2aa8..0ba6b434 100644 --- a/src/main/java/com/chargebee/v4/models/coupon/responses/CouponRetrieveResponse.java +++ b/src/main/java/com/chargebee/v4/models/coupon/responses/CouponRetrieveResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static CouponRetrieveResponse fromJson(String json) { /** Parse JSON response into CouponRetrieveResponse object with HTTP response. */ public static CouponRetrieveResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __couponJson = JsonUtil.getObject(json, "coupon"); - if (__couponJson != null) { - builder.coupon(Coupon.fromJson(__couponJson)); + JsonObject __couponObj = JsonUtil.getJsonObject(jsonObj, "coupon"); + if (__couponObj != null) { + builder.coupon(Coupon.fromJson(__couponObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/coupon/responses/CouponUnarchiveResponse.java b/src/main/java/com/chargebee/v4/models/coupon/responses/CouponUnarchiveResponse.java index 95c5776f..3e04aec2 100644 --- a/src/main/java/com/chargebee/v4/models/coupon/responses/CouponUnarchiveResponse.java +++ b/src/main/java/com/chargebee/v4/models/coupon/responses/CouponUnarchiveResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -26,11 +27,12 @@ public static CouponUnarchiveResponse fromJson(String json) { /** Parse JSON response into CouponUnarchiveResponse object with HTTP response. */ public static CouponUnarchiveResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __couponJson = JsonUtil.getObject(json, "coupon"); - if (__couponJson != null) { - builder.coupon(Coupon.fromJson(__couponJson)); + JsonObject __couponObj = JsonUtil.getJsonObject(jsonObj, "coupon"); + if (__couponObj != null) { + builder.coupon(Coupon.fromJson(__couponObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/coupon/responses/CouponUpdateForItemsResponse.java b/src/main/java/com/chargebee/v4/models/coupon/responses/CouponUpdateForItemsResponse.java index 869d0c84..aa4d3060 100644 --- a/src/main/java/com/chargebee/v4/models/coupon/responses/CouponUpdateForItemsResponse.java +++ b/src/main/java/com/chargebee/v4/models/coupon/responses/CouponUpdateForItemsResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static CouponUpdateForItemsResponse fromJson(String json) { /** Parse JSON response into CouponUpdateForItemsResponse object with HTTP response. */ public static CouponUpdateForItemsResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __couponJson = JsonUtil.getObject(json, "coupon"); - if (__couponJson != null) { - builder.coupon(Coupon.fromJson(__couponJson)); + JsonObject __couponObj = JsonUtil.getJsonObject(jsonObj, "coupon"); + if (__couponObj != null) { + builder.coupon(Coupon.fromJson(__couponObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/coupon/responses/CouponUpdateResponse.java b/src/main/java/com/chargebee/v4/models/coupon/responses/CouponUpdateResponse.java index befbd60f..9017fba2 100644 --- a/src/main/java/com/chargebee/v4/models/coupon/responses/CouponUpdateResponse.java +++ b/src/main/java/com/chargebee/v4/models/coupon/responses/CouponUpdateResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -26,11 +27,12 @@ public static CouponUpdateResponse fromJson(String json) { /** Parse JSON response into CouponUpdateResponse object with HTTP response. */ public static CouponUpdateResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __couponJson = JsonUtil.getObject(json, "coupon"); - if (__couponJson != null) { - builder.coupon(Coupon.fromJson(__couponJson)); + JsonObject __couponObj = JsonUtil.getJsonObject(jsonObj, "coupon"); + if (__couponObj != null) { + builder.coupon(Coupon.fromJson(__couponObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/couponCode/CouponCode.java b/src/main/java/com/chargebee/v4/models/couponCode/CouponCode.java index 0e8985d0..51db800a 100644 --- a/src/main/java/com/chargebee/v4/models/couponCode/CouponCode.java +++ b/src/main/java/com/chargebee/v4/models/couponCode/CouponCode.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.couponCode; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; public class CouponCode { @@ -68,17 +69,21 @@ public static Status fromString(String value) { } public static CouponCode fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static CouponCode fromJson(JsonObject jsonObj) { CouponCode obj = new CouponCode(); - obj.code = JsonUtil.getString(json, "code"); + obj.code = JsonUtil.getString(jsonObj, "code"); - obj.status = Status.fromString(JsonUtil.getString(json, "status")); + obj.status = Status.fromString(JsonUtil.getString(jsonObj, "status")); - obj.couponId = JsonUtil.getString(json, "coupon_id"); + obj.couponId = JsonUtil.getString(jsonObj, "coupon_id"); - obj.couponSetId = JsonUtil.getString(json, "coupon_set_id"); + obj.couponSetId = JsonUtil.getString(jsonObj, "coupon_set_id"); - obj.couponSetName = JsonUtil.getString(json, "coupon_set_name"); + obj.couponSetName = JsonUtil.getString(jsonObj, "coupon_set_name"); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/couponCode/responses/CouponCodeArchiveResponse.java b/src/main/java/com/chargebee/v4/models/couponCode/responses/CouponCodeArchiveResponse.java index a3b621b6..61f21d9a 100644 --- a/src/main/java/com/chargebee/v4/models/couponCode/responses/CouponCodeArchiveResponse.java +++ b/src/main/java/com/chargebee/v4/models/couponCode/responses/CouponCodeArchiveResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static CouponCodeArchiveResponse fromJson(String json) { /** Parse JSON response into CouponCodeArchiveResponse object with HTTP response. */ public static CouponCodeArchiveResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __couponCodeJson = JsonUtil.getObject(json, "coupon_code"); - if (__couponCodeJson != null) { - builder.couponCode(CouponCode.fromJson(__couponCodeJson)); + JsonObject __couponCodeObj = JsonUtil.getJsonObject(jsonObj, "coupon_code"); + if (__couponCodeObj != null) { + builder.couponCode(CouponCode.fromJson(__couponCodeObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/couponCode/responses/CouponCodeCreateResponse.java b/src/main/java/com/chargebee/v4/models/couponCode/responses/CouponCodeCreateResponse.java index bd1fdbb9..e149b624 100644 --- a/src/main/java/com/chargebee/v4/models/couponCode/responses/CouponCodeCreateResponse.java +++ b/src/main/java/com/chargebee/v4/models/couponCode/responses/CouponCodeCreateResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static CouponCodeCreateResponse fromJson(String json) { /** Parse JSON response into CouponCodeCreateResponse object with HTTP response. */ public static CouponCodeCreateResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __couponCodeJson = JsonUtil.getObject(json, "coupon_code"); - if (__couponCodeJson != null) { - builder.couponCode(CouponCode.fromJson(__couponCodeJson)); + JsonObject __couponCodeObj = JsonUtil.getJsonObject(jsonObj, "coupon_code"); + if (__couponCodeObj != null) { + builder.couponCode(CouponCode.fromJson(__couponCodeObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/couponCode/responses/CouponCodeListResponse.java b/src/main/java/com/chargebee/v4/models/couponCode/responses/CouponCodeListResponse.java index 369175bd..e16c6a89 100644 --- a/src/main/java/com/chargebee/v4/models/couponCode/responses/CouponCodeListResponse.java +++ b/src/main/java/com/chargebee/v4/models/couponCode/responses/CouponCodeListResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.exceptions.ChargebeeException; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; import com.chargebee.v4.services.CouponCodeService; import com.chargebee.v4.models.couponCode.params.CouponCodeListParams; @@ -43,13 +44,12 @@ private CouponCodeListResponse( */ public static CouponCodeListResponse fromJson(String json) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(CouponCodeListItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "list"), CouponCodeListItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new CouponCodeListResponse(list, nextOffset, null, null, null); } catch (Exception e) { @@ -67,13 +67,12 @@ public static CouponCodeListResponse fromJson( CouponCodeListParams originalParams, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(CouponCodeListItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "list"), CouponCodeListItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new CouponCodeListResponse(list, nextOffset, service, originalParams, httpResponse); } catch (Exception e) { @@ -173,11 +172,15 @@ public CouponCode getCouponCode() { } public static CouponCodeListItem fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static CouponCodeListItem fromJson(JsonObject jsonObj) { CouponCodeListItem item = new CouponCodeListItem(); - String __couponCodeJson = JsonUtil.getObject(json, "coupon_code"); - if (__couponCodeJson != null) { - item.couponCode = CouponCode.fromJson(__couponCodeJson); + JsonObject __couponCodeObj = JsonUtil.getJsonObject(jsonObj, "coupon_code"); + if (__couponCodeObj != null) { + item.couponCode = CouponCode.fromJson(__couponCodeObj); } return item; diff --git a/src/main/java/com/chargebee/v4/models/couponCode/responses/CouponCodeRetrieveResponse.java b/src/main/java/com/chargebee/v4/models/couponCode/responses/CouponCodeRetrieveResponse.java index ad0b356a..f9eb18ac 100644 --- a/src/main/java/com/chargebee/v4/models/couponCode/responses/CouponCodeRetrieveResponse.java +++ b/src/main/java/com/chargebee/v4/models/couponCode/responses/CouponCodeRetrieveResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static CouponCodeRetrieveResponse fromJson(String json) { /** Parse JSON response into CouponCodeRetrieveResponse object with HTTP response. */ public static CouponCodeRetrieveResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __couponCodeJson = JsonUtil.getObject(json, "coupon_code"); - if (__couponCodeJson != null) { - builder.couponCode(CouponCode.fromJson(__couponCodeJson)); + JsonObject __couponCodeObj = JsonUtil.getJsonObject(jsonObj, "coupon_code"); + if (__couponCodeObj != null) { + builder.couponCode(CouponCode.fromJson(__couponCodeObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/couponSet/CouponSet.java b/src/main/java/com/chargebee/v4/models/couponSet/CouponSet.java index 8620e834..b9c09517 100644 --- a/src/main/java/com/chargebee/v4/models/couponSet/CouponSet.java +++ b/src/main/java/com/chargebee/v4/models/couponSet/CouponSet.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.couponSet; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; public class CouponSet { @@ -48,24 +49,28 @@ public java.util.Map getMetaData() { } public static CouponSet fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static CouponSet fromJson(JsonObject jsonObj) { CouponSet obj = new CouponSet(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.couponId = JsonUtil.getString(json, "coupon_id"); + obj.couponId = JsonUtil.getString(jsonObj, "coupon_id"); - obj.name = JsonUtil.getString(json, "name"); + obj.name = JsonUtil.getString(jsonObj, "name"); - obj.totalCount = JsonUtil.getInteger(json, "total_count"); + obj.totalCount = JsonUtil.getInteger(jsonObj, "total_count"); - obj.redeemedCount = JsonUtil.getInteger(json, "redeemed_count"); + obj.redeemedCount = JsonUtil.getInteger(jsonObj, "redeemed_count"); - obj.archivedCount = JsonUtil.getInteger(json, "archived_count"); + obj.archivedCount = JsonUtil.getInteger(jsonObj, "archived_count"); - String __metaDataJson = JsonUtil.getObject(json, "meta_data"); + JsonObject __metaDataObj = JsonUtil.getJsonObject(jsonObj, "meta_data"); obj.metaData = - __metaDataJson != null - ? JsonUtil.parseJsonObjectToMap(__metaDataJson) + __metaDataObj != null + ? JsonUtil.parseJsonObjectToMap(__metaDataObj) : new java.util.HashMap<>(); return obj; diff --git a/src/main/java/com/chargebee/v4/models/couponSet/responses/CouponSetAddCouponCodesResponse.java b/src/main/java/com/chargebee/v4/models/couponSet/responses/CouponSetAddCouponCodesResponse.java index 151964d8..6beb7bea 100644 --- a/src/main/java/com/chargebee/v4/models/couponSet/responses/CouponSetAddCouponCodesResponse.java +++ b/src/main/java/com/chargebee/v4/models/couponSet/responses/CouponSetAddCouponCodesResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static CouponSetAddCouponCodesResponse fromJson(String json) { /** Parse JSON response into CouponSetAddCouponCodesResponse object with HTTP response. */ public static CouponSetAddCouponCodesResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __couponSetJson = JsonUtil.getObject(json, "coupon_set"); - if (__couponSetJson != null) { - builder.couponSet(CouponSet.fromJson(__couponSetJson)); + JsonObject __couponSetObj = JsonUtil.getJsonObject(jsonObj, "coupon_set"); + if (__couponSetObj != null) { + builder.couponSet(CouponSet.fromJson(__couponSetObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/couponSet/responses/CouponSetCreateResponse.java b/src/main/java/com/chargebee/v4/models/couponSet/responses/CouponSetCreateResponse.java index ec58121a..8a9a0e30 100644 --- a/src/main/java/com/chargebee/v4/models/couponSet/responses/CouponSetCreateResponse.java +++ b/src/main/java/com/chargebee/v4/models/couponSet/responses/CouponSetCreateResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -26,11 +27,12 @@ public static CouponSetCreateResponse fromJson(String json) { /** Parse JSON response into CouponSetCreateResponse object with HTTP response. */ public static CouponSetCreateResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __couponSetJson = JsonUtil.getObject(json, "coupon_set"); - if (__couponSetJson != null) { - builder.couponSet(CouponSet.fromJson(__couponSetJson)); + JsonObject __couponSetObj = JsonUtil.getJsonObject(jsonObj, "coupon_set"); + if (__couponSetObj != null) { + builder.couponSet(CouponSet.fromJson(__couponSetObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/couponSet/responses/CouponSetDeleteResponse.java b/src/main/java/com/chargebee/v4/models/couponSet/responses/CouponSetDeleteResponse.java index 7c46b8bb..75e014c5 100644 --- a/src/main/java/com/chargebee/v4/models/couponSet/responses/CouponSetDeleteResponse.java +++ b/src/main/java/com/chargebee/v4/models/couponSet/responses/CouponSetDeleteResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -26,11 +27,12 @@ public static CouponSetDeleteResponse fromJson(String json) { /** Parse JSON response into CouponSetDeleteResponse object with HTTP response. */ public static CouponSetDeleteResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __couponSetJson = JsonUtil.getObject(json, "coupon_set"); - if (__couponSetJson != null) { - builder.couponSet(CouponSet.fromJson(__couponSetJson)); + JsonObject __couponSetObj = JsonUtil.getJsonObject(jsonObj, "coupon_set"); + if (__couponSetObj != null) { + builder.couponSet(CouponSet.fromJson(__couponSetObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/couponSet/responses/CouponSetDeleteUnusedCouponCodesResponse.java b/src/main/java/com/chargebee/v4/models/couponSet/responses/CouponSetDeleteUnusedCouponCodesResponse.java index a82b1781..af6ee7b2 100644 --- a/src/main/java/com/chargebee/v4/models/couponSet/responses/CouponSetDeleteUnusedCouponCodesResponse.java +++ b/src/main/java/com/chargebee/v4/models/couponSet/responses/CouponSetDeleteUnusedCouponCodesResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -30,11 +31,12 @@ public static CouponSetDeleteUnusedCouponCodesResponse fromJson(String json) { public static CouponSetDeleteUnusedCouponCodesResponse fromJson( String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __couponSetJson = JsonUtil.getObject(json, "coupon_set"); - if (__couponSetJson != null) { - builder.couponSet(CouponSet.fromJson(__couponSetJson)); + JsonObject __couponSetObj = JsonUtil.getJsonObject(jsonObj, "coupon_set"); + if (__couponSetObj != null) { + builder.couponSet(CouponSet.fromJson(__couponSetObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/couponSet/responses/CouponSetListResponse.java b/src/main/java/com/chargebee/v4/models/couponSet/responses/CouponSetListResponse.java index 8e230184..5e80a38d 100644 --- a/src/main/java/com/chargebee/v4/models/couponSet/responses/CouponSetListResponse.java +++ b/src/main/java/com/chargebee/v4/models/couponSet/responses/CouponSetListResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.exceptions.ChargebeeException; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; import com.chargebee.v4.services.CouponSetService; import com.chargebee.v4.models.couponSet.params.CouponSetListParams; @@ -43,13 +44,12 @@ private CouponSetListResponse( */ public static CouponSetListResponse fromJson(String json) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(CouponSetListItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "list"), CouponSetListItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new CouponSetListResponse(list, nextOffset, null, null, null); } catch (Exception e) { @@ -67,13 +67,12 @@ public static CouponSetListResponse fromJson( CouponSetListParams originalParams, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(CouponSetListItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "list"), CouponSetListItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new CouponSetListResponse(list, nextOffset, service, originalParams, httpResponse); } catch (Exception e) { @@ -173,11 +172,15 @@ public CouponSet getCouponSet() { } public static CouponSetListItem fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static CouponSetListItem fromJson(JsonObject jsonObj) { CouponSetListItem item = new CouponSetListItem(); - String __couponSetJson = JsonUtil.getObject(json, "coupon_set"); - if (__couponSetJson != null) { - item.couponSet = CouponSet.fromJson(__couponSetJson); + JsonObject __couponSetObj = JsonUtil.getJsonObject(jsonObj, "coupon_set"); + if (__couponSetObj != null) { + item.couponSet = CouponSet.fromJson(__couponSetObj); } return item; diff --git a/src/main/java/com/chargebee/v4/models/couponSet/responses/CouponSetRetrieveResponse.java b/src/main/java/com/chargebee/v4/models/couponSet/responses/CouponSetRetrieveResponse.java index 421cd43d..d5577a6f 100644 --- a/src/main/java/com/chargebee/v4/models/couponSet/responses/CouponSetRetrieveResponse.java +++ b/src/main/java/com/chargebee/v4/models/couponSet/responses/CouponSetRetrieveResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static CouponSetRetrieveResponse fromJson(String json) { /** Parse JSON response into CouponSetRetrieveResponse object with HTTP response. */ public static CouponSetRetrieveResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __couponSetJson = JsonUtil.getObject(json, "coupon_set"); - if (__couponSetJson != null) { - builder.couponSet(CouponSet.fromJson(__couponSetJson)); + JsonObject __couponSetObj = JsonUtil.getJsonObject(jsonObj, "coupon_set"); + if (__couponSetObj != null) { + builder.couponSet(CouponSet.fromJson(__couponSetObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/couponSet/responses/CouponSetUpdateResponse.java b/src/main/java/com/chargebee/v4/models/couponSet/responses/CouponSetUpdateResponse.java index 6cd15a3a..22166f50 100644 --- a/src/main/java/com/chargebee/v4/models/couponSet/responses/CouponSetUpdateResponse.java +++ b/src/main/java/com/chargebee/v4/models/couponSet/responses/CouponSetUpdateResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -26,11 +27,12 @@ public static CouponSetUpdateResponse fromJson(String json) { /** Parse JSON response into CouponSetUpdateResponse object with HTTP response. */ public static CouponSetUpdateResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __couponSetJson = JsonUtil.getObject(json, "coupon_set"); - if (__couponSetJson != null) { - builder.couponSet(CouponSet.fromJson(__couponSetJson)); + JsonObject __couponSetObj = JsonUtil.getJsonObject(jsonObj, "coupon_set"); + if (__couponSetObj != null) { + builder.couponSet(CouponSet.fromJson(__couponSetObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/creditNote/CreditNote.java b/src/main/java/com/chargebee/v4/models/creditNote/CreditNote.java index 8ae29351..896406fe 100644 --- a/src/main/java/com/chargebee/v4/models/creditNote/CreditNote.java +++ b/src/main/java/com/chargebee/v4/models/creditNote/CreditNote.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.creditNote; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import java.math.BigDecimal; import java.sql.Timestamp; import java.util.List; @@ -446,9 +447,12 @@ public static Channel fromString(String value) { } public static CreditNote fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static CreditNote fromJson(JsonObject jsonObj) { CreditNote obj = new CreditNote(); - // Parse JSON to extract all keys for custom field extraction java.util.Set knownFields = new java.util.HashSet<>(); knownFields.add("id"); @@ -547,180 +551,136 @@ public static CreditNote fromJson(String json) { knownFields.add("site_details_at_creation"); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.customerId = JsonUtil.getString(json, "customer_id"); + obj.customerId = JsonUtil.getString(jsonObj, "customer_id"); - obj.subscriptionId = JsonUtil.getString(json, "subscription_id"); + obj.subscriptionId = JsonUtil.getString(jsonObj, "subscription_id"); - obj.referenceInvoiceId = JsonUtil.getString(json, "reference_invoice_id"); + obj.referenceInvoiceId = JsonUtil.getString(jsonObj, "reference_invoice_id"); - obj.type = Type.fromString(JsonUtil.getString(json, "type")); + obj.type = Type.fromString(JsonUtil.getString(jsonObj, "type")); - obj.reasonCode = ReasonCode.fromString(JsonUtil.getString(json, "reason_code")); + obj.reasonCode = ReasonCode.fromString(JsonUtil.getString(jsonObj, "reason_code")); - obj.status = Status.fromString(JsonUtil.getString(json, "status")); + obj.status = Status.fromString(JsonUtil.getString(jsonObj, "status")); - obj.vatNumber = JsonUtil.getString(json, "vat_number"); + obj.vatNumber = JsonUtil.getString(jsonObj, "vat_number"); - obj.date = JsonUtil.getTimestamp(json, "date"); + obj.date = JsonUtil.getTimestamp(jsonObj, "date"); - obj.priceType = PriceType.fromString(JsonUtil.getString(json, "price_type")); + obj.priceType = PriceType.fromString(JsonUtil.getString(jsonObj, "price_type")); - obj.currencyCode = JsonUtil.getString(json, "currency_code"); + obj.currencyCode = JsonUtil.getString(jsonObj, "currency_code"); - obj.total = JsonUtil.getLong(json, "total"); + obj.total = JsonUtil.getLong(jsonObj, "total"); - obj.amountAllocated = JsonUtil.getLong(json, "amount_allocated"); + obj.amountAllocated = JsonUtil.getLong(jsonObj, "amount_allocated"); - obj.amountRefunded = JsonUtil.getLong(json, "amount_refunded"); + obj.amountRefunded = JsonUtil.getLong(jsonObj, "amount_refunded"); - obj.amountAvailable = JsonUtil.getLong(json, "amount_available"); + obj.amountAvailable = JsonUtil.getLong(jsonObj, "amount_available"); - obj.refundedAt = JsonUtil.getTimestamp(json, "refunded_at"); + obj.refundedAt = JsonUtil.getTimestamp(jsonObj, "refunded_at"); - obj.voidedAt = JsonUtil.getTimestamp(json, "voided_at"); + obj.voidedAt = JsonUtil.getTimestamp(jsonObj, "voided_at"); - obj.generatedAt = JsonUtil.getTimestamp(json, "generated_at"); + obj.generatedAt = JsonUtil.getTimestamp(jsonObj, "generated_at"); - obj.resourceVersion = JsonUtil.getLong(json, "resource_version"); + obj.resourceVersion = JsonUtil.getLong(jsonObj, "resource_version"); - obj.updatedAt = JsonUtil.getTimestamp(json, "updated_at"); + obj.updatedAt = JsonUtil.getTimestamp(jsonObj, "updated_at"); - obj.channel = Channel.fromString(JsonUtil.getString(json, "channel")); + obj.channel = Channel.fromString(JsonUtil.getString(jsonObj, "channel")); - obj.lineItemsNextOffset = JsonUtil.getString(json, "line_items_next_offset"); + obj.lineItemsNextOffset = JsonUtil.getString(jsonObj, "line_items_next_offset"); - obj.subTotal = JsonUtil.getLong(json, "sub_total"); + obj.subTotal = JsonUtil.getLong(jsonObj, "sub_total"); - obj.subTotalInLocalCurrency = JsonUtil.getLong(json, "sub_total_in_local_currency"); + obj.subTotalInLocalCurrency = JsonUtil.getLong(jsonObj, "sub_total_in_local_currency"); - obj.totalInLocalCurrency = JsonUtil.getLong(json, "total_in_local_currency"); + obj.totalInLocalCurrency = JsonUtil.getLong(jsonObj, "total_in_local_currency"); - obj.localCurrencyCode = JsonUtil.getString(json, "local_currency_code"); + obj.localCurrencyCode = JsonUtil.getString(jsonObj, "local_currency_code"); - obj.roundOffAmount = JsonUtil.getLong(json, "round_off_amount"); + obj.roundOffAmount = JsonUtil.getLong(jsonObj, "round_off_amount"); - obj.fractionalCorrection = JsonUtil.getLong(json, "fractional_correction"); + obj.fractionalCorrection = JsonUtil.getLong(jsonObj, "fractional_correction"); - obj.deleted = JsonUtil.getBoolean(json, "deleted"); + obj.deleted = JsonUtil.getBoolean(jsonObj, "deleted"); - obj.taxCategory = JsonUtil.getString(json, "tax_category"); + obj.taxCategory = JsonUtil.getString(jsonObj, "tax_category"); - obj.localCurrencyExchangeRate = JsonUtil.getBigDecimal(json, "local_currency_exchange_rate"); + obj.localCurrencyExchangeRate = JsonUtil.getBigDecimal(jsonObj, "local_currency_exchange_rate"); - obj.createReasonCode = JsonUtil.getString(json, "create_reason_code"); + obj.createReasonCode = JsonUtil.getString(jsonObj, "create_reason_code"); - obj.vatNumberPrefix = JsonUtil.getString(json, "vat_number_prefix"); + obj.vatNumberPrefix = JsonUtil.getString(jsonObj, "vat_number_prefix"); - obj.businessEntityId = JsonUtil.getString(json, "business_entity_id"); + obj.businessEntityId = JsonUtil.getString(jsonObj, "business_entity_id"); obj.lineItems = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "line_items")).stream() - .map(LineItems::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "line_items"), LineItems::fromJson); obj.lineItemTiers = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "line_item_tiers")).stream() - .map(LineItemTiers::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "line_item_tiers"), LineItemTiers::fromJson); obj.lineItemDiscounts = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "line_item_discounts")).stream() - .map(LineItemDiscounts::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "line_item_discounts"), LineItemDiscounts::fromJson); obj.lineItemTaxes = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "line_item_taxes")).stream() - .map(LineItemTaxes::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "line_item_taxes"), LineItemTaxes::fromJson); obj.lineItemAddresses = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "line_item_addresses")).stream() - .map(LineItemAddresses::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "line_item_addresses"), LineItemAddresses::fromJson); obj.discounts = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "discounts")).stream() - .map(Discounts::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "discounts"), Discounts::fromJson); - obj.taxes = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "taxes")).stream() - .map(Taxes::fromJson) - .collect(java.util.stream.Collectors.toList()); + obj.taxes = JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "taxes"), Taxes::fromJson); - String __taxOriginJson = JsonUtil.getObject(json, "tax_origin"); - if (__taxOriginJson != null) { - obj.taxOrigin = TaxOrigin.fromJson(__taxOriginJson); + JsonObject __taxOriginObj = JsonUtil.getJsonObject(jsonObj, "tax_origin"); + if (__taxOriginObj != null) { + obj.taxOrigin = TaxOrigin.fromJson(__taxOriginObj); } obj.linkedRefunds = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "linked_refunds")).stream() - .map(LinkedRefunds::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "linked_refunds"), LinkedRefunds::fromJson); obj.allocations = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "allocations")).stream() - .map(Allocations::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "allocations"), Allocations::fromJson); - String __shippingAddressJson = JsonUtil.getObject(json, "shipping_address"); - if (__shippingAddressJson != null) { - obj.shippingAddress = ShippingAddress.fromJson(__shippingAddressJson); + JsonObject __shippingAddressObj = JsonUtil.getJsonObject(jsonObj, "shipping_address"); + if (__shippingAddressObj != null) { + obj.shippingAddress = ShippingAddress.fromJson(__shippingAddressObj); } - String __billingAddressJson = JsonUtil.getObject(json, "billing_address"); - if (__billingAddressJson != null) { - obj.billingAddress = BillingAddress.fromJson(__billingAddressJson); + JsonObject __billingAddressObj = JsonUtil.getJsonObject(jsonObj, "billing_address"); + if (__billingAddressObj != null) { + obj.billingAddress = BillingAddress.fromJson(__billingAddressObj); } - String __einvoiceJson = JsonUtil.getObject(json, "einvoice"); - if (__einvoiceJson != null) { - obj.einvoice = Einvoice.fromJson(__einvoiceJson); + JsonObject __einvoiceObj = JsonUtil.getJsonObject(jsonObj, "einvoice"); + if (__einvoiceObj != null) { + obj.einvoice = Einvoice.fromJson(__einvoiceObj); } - String __siteDetailsAtCreationJson = JsonUtil.getObject(json, "site_details_at_creation"); - if (__siteDetailsAtCreationJson != null) { - obj.siteDetailsAtCreation = SiteDetailsAtCreation.fromJson(__siteDetailsAtCreationJson); + JsonObject __siteDetailsAtCreationObj = + JsonUtil.getJsonObject(jsonObj, "site_details_at_creation"); + if (__siteDetailsAtCreationObj != null) { + obj.siteDetailsAtCreation = SiteDetailsAtCreation.fromJson(__siteDetailsAtCreationObj); } - // Extract custom fields (fields starting with cf_) - obj.customFields = extractCustomFields(json, knownFields); + obj.customFields = JsonUtil.extractCustomFields(jsonObj, knownFields); return obj; } - /** - * Helper method to extract custom fields from JSON. Custom fields are fields that start with - * "cf_" and are not in the known fields set. - * - * @param json JSON string to parse - * @param knownFields set of known field names - * @return map of custom fields - */ - private static java.util.Map extractCustomFields( - String json, java.util.Set knownFields) { - java.util.Map customFields = new java.util.HashMap<>(); - try { - // Parse the entire JSON as a map - java.util.Map allFields = JsonUtil.parseJsonObjectToMap(json); - if (allFields != null) { - for (java.util.Map.Entry entry : allFields.entrySet()) { - String key = entry.getKey(); - // Include fields that start with "cf_" and are not in knownFields - if (key != null && key.startsWith("cf_") && !knownFields.contains(key)) { - customFields.put( - key, entry.getValue() != null ? String.valueOf(entry.getValue()) : null); - } - } - } - } catch (Exception e) { - // If parsing fails, return empty map - } - return customFields; - } - @Override public String toString() { return "CreditNote{" @@ -1182,58 +1142,62 @@ public static TaxExemptReason fromString(String value) { } public static LineItems fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static LineItems fromJson(JsonObject jsonObj) { LineItems obj = new LineItems(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.subscriptionId = JsonUtil.getString(json, "subscription_id"); + obj.subscriptionId = JsonUtil.getString(jsonObj, "subscription_id"); - obj.dateFrom = JsonUtil.getTimestamp(json, "date_from"); + obj.dateFrom = JsonUtil.getTimestamp(jsonObj, "date_from"); - obj.dateTo = JsonUtil.getTimestamp(json, "date_to"); + obj.dateTo = JsonUtil.getTimestamp(jsonObj, "date_to"); - obj.unitAmount = JsonUtil.getLong(json, "unit_amount"); + obj.unitAmount = JsonUtil.getLong(jsonObj, "unit_amount"); - obj.quantity = JsonUtil.getInteger(json, "quantity"); + obj.quantity = JsonUtil.getInteger(jsonObj, "quantity"); - obj.amount = JsonUtil.getLong(json, "amount"); + obj.amount = JsonUtil.getLong(jsonObj, "amount"); - obj.pricingModel = PricingModel.fromString(JsonUtil.getString(json, "pricing_model")); + obj.pricingModel = PricingModel.fromString(JsonUtil.getString(jsonObj, "pricing_model")); - obj.isTaxed = JsonUtil.getBoolean(json, "is_taxed"); + obj.isTaxed = JsonUtil.getBoolean(jsonObj, "is_taxed"); - obj.taxAmount = JsonUtil.getLong(json, "tax_amount"); + obj.taxAmount = JsonUtil.getLong(jsonObj, "tax_amount"); - obj.taxRate = JsonUtil.getDouble(json, "tax_rate"); + obj.taxRate = JsonUtil.getDouble(jsonObj, "tax_rate"); - obj.unitAmountInDecimal = JsonUtil.getString(json, "unit_amount_in_decimal"); + obj.unitAmountInDecimal = JsonUtil.getString(jsonObj, "unit_amount_in_decimal"); - obj.quantityInDecimal = JsonUtil.getString(json, "quantity_in_decimal"); + obj.quantityInDecimal = JsonUtil.getString(jsonObj, "quantity_in_decimal"); - obj.amountInDecimal = JsonUtil.getString(json, "amount_in_decimal"); + obj.amountInDecimal = JsonUtil.getString(jsonObj, "amount_in_decimal"); - obj.discountAmount = JsonUtil.getLong(json, "discount_amount"); + obj.discountAmount = JsonUtil.getLong(jsonObj, "discount_amount"); - obj.itemLevelDiscountAmount = JsonUtil.getLong(json, "item_level_discount_amount"); + obj.itemLevelDiscountAmount = JsonUtil.getLong(jsonObj, "item_level_discount_amount"); - obj.metered = JsonUtil.getBoolean(json, "metered"); + obj.metered = JsonUtil.getBoolean(jsonObj, "metered"); - obj.isPercentagePricing = JsonUtil.getBoolean(json, "is_percentage_pricing"); + obj.isPercentagePricing = JsonUtil.getBoolean(jsonObj, "is_percentage_pricing"); - obj.referenceLineItemId = JsonUtil.getString(json, "reference_line_item_id"); + obj.referenceLineItemId = JsonUtil.getString(jsonObj, "reference_line_item_id"); - obj.description = JsonUtil.getString(json, "description"); + obj.description = JsonUtil.getString(jsonObj, "description"); - obj.entityDescription = JsonUtil.getString(json, "entity_description"); + obj.entityDescription = JsonUtil.getString(jsonObj, "entity_description"); - obj.entityType = EntityType.fromString(JsonUtil.getString(json, "entity_type")); + obj.entityType = EntityType.fromString(JsonUtil.getString(jsonObj, "entity_type")); obj.taxExemptReason = - TaxExemptReason.fromString(JsonUtil.getString(json, "tax_exempt_reason")); + TaxExemptReason.fromString(JsonUtil.getString(jsonObj, "tax_exempt_reason")); - obj.entityId = JsonUtil.getString(json, "entity_id"); + obj.entityId = JsonUtil.getString(jsonObj, "entity_id"); - obj.customerId = JsonUtil.getString(json, "customer_id"); + obj.customerId = JsonUtil.getString(jsonObj, "customer_id"); return obj; } @@ -1448,29 +1412,33 @@ public static PricingType fromString(String value) { } public static LineItemTiers fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static LineItemTiers fromJson(JsonObject jsonObj) { LineItemTiers obj = new LineItemTiers(); - obj.lineItemId = JsonUtil.getString(json, "line_item_id"); + obj.lineItemId = JsonUtil.getString(jsonObj, "line_item_id"); - obj.startingUnit = JsonUtil.getInteger(json, "starting_unit"); + obj.startingUnit = JsonUtil.getInteger(jsonObj, "starting_unit"); - obj.endingUnit = JsonUtil.getInteger(json, "ending_unit"); + obj.endingUnit = JsonUtil.getInteger(jsonObj, "ending_unit"); - obj.quantityUsed = JsonUtil.getInteger(json, "quantity_used"); + obj.quantityUsed = JsonUtil.getInteger(jsonObj, "quantity_used"); - obj.unitAmount = JsonUtil.getLong(json, "unit_amount"); + obj.unitAmount = JsonUtil.getLong(jsonObj, "unit_amount"); - obj.startingUnitInDecimal = JsonUtil.getString(json, "starting_unit_in_decimal"); + obj.startingUnitInDecimal = JsonUtil.getString(jsonObj, "starting_unit_in_decimal"); - obj.endingUnitInDecimal = JsonUtil.getString(json, "ending_unit_in_decimal"); + obj.endingUnitInDecimal = JsonUtil.getString(jsonObj, "ending_unit_in_decimal"); - obj.quantityUsedInDecimal = JsonUtil.getString(json, "quantity_used_in_decimal"); + obj.quantityUsedInDecimal = JsonUtil.getString(jsonObj, "quantity_used_in_decimal"); - obj.unitAmountInDecimal = JsonUtil.getString(json, "unit_amount_in_decimal"); + obj.unitAmountInDecimal = JsonUtil.getString(jsonObj, "unit_amount_in_decimal"); - obj.pricingType = PricingType.fromString(JsonUtil.getString(json, "pricing_type")); + obj.pricingType = PricingType.fromString(JsonUtil.getString(jsonObj, "pricing_type")); - obj.packageSize = JsonUtil.getInteger(json, "package_size"); + obj.packageSize = JsonUtil.getInteger(jsonObj, "package_size"); return obj; } @@ -1605,17 +1573,21 @@ public static DiscountType fromString(String value) { } public static LineItemDiscounts fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static LineItemDiscounts fromJson(JsonObject jsonObj) { LineItemDiscounts obj = new LineItemDiscounts(); - obj.lineItemId = JsonUtil.getString(json, "line_item_id"); + obj.lineItemId = JsonUtil.getString(jsonObj, "line_item_id"); - obj.discountType = DiscountType.fromString(JsonUtil.getString(json, "discount_type")); + obj.discountType = DiscountType.fromString(JsonUtil.getString(jsonObj, "discount_type")); - obj.couponId = JsonUtil.getString(json, "coupon_id"); + obj.couponId = JsonUtil.getString(jsonObj, "coupon_id"); - obj.entityId = JsonUtil.getString(json, "entity_id"); + obj.entityId = JsonUtil.getString(jsonObj, "entity_id"); - obj.discountAmount = JsonUtil.getLong(json, "discount_amount"); + obj.discountAmount = JsonUtil.getLong(jsonObj, "discount_amount"); return obj; } @@ -1775,37 +1747,41 @@ public static TaxJurisType fromString(String value) { } public static LineItemTaxes fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static LineItemTaxes fromJson(JsonObject jsonObj) { LineItemTaxes obj = new LineItemTaxes(); - obj.lineItemId = JsonUtil.getString(json, "line_item_id"); + obj.lineItemId = JsonUtil.getString(jsonObj, "line_item_id"); - obj.taxName = JsonUtil.getString(json, "tax_name"); + obj.taxName = JsonUtil.getString(jsonObj, "tax_name"); - obj.taxRate = JsonUtil.getDouble(json, "tax_rate"); + obj.taxRate = JsonUtil.getDouble(jsonObj, "tax_rate"); - obj.dateTo = JsonUtil.getTimestamp(json, "date_to"); + obj.dateTo = JsonUtil.getTimestamp(jsonObj, "date_to"); - obj.dateFrom = JsonUtil.getTimestamp(json, "date_from"); + obj.dateFrom = JsonUtil.getTimestamp(jsonObj, "date_from"); - obj.proratedTaxableAmount = JsonUtil.getBigDecimal(json, "prorated_taxable_amount"); + obj.proratedTaxableAmount = JsonUtil.getBigDecimal(jsonObj, "prorated_taxable_amount"); - obj.isPartialTaxApplied = JsonUtil.getBoolean(json, "is_partial_tax_applied"); + obj.isPartialTaxApplied = JsonUtil.getBoolean(jsonObj, "is_partial_tax_applied"); - obj.isNonComplianceTax = JsonUtil.getBoolean(json, "is_non_compliance_tax"); + obj.isNonComplianceTax = JsonUtil.getBoolean(jsonObj, "is_non_compliance_tax"); - obj.taxableAmount = JsonUtil.getLong(json, "taxable_amount"); + obj.taxableAmount = JsonUtil.getLong(jsonObj, "taxable_amount"); - obj.taxAmount = JsonUtil.getLong(json, "tax_amount"); + obj.taxAmount = JsonUtil.getLong(jsonObj, "tax_amount"); - obj.taxJurisType = TaxJurisType.fromString(JsonUtil.getString(json, "tax_juris_type")); + obj.taxJurisType = TaxJurisType.fromString(JsonUtil.getString(jsonObj, "tax_juris_type")); - obj.taxJurisName = JsonUtil.getString(json, "tax_juris_name"); + obj.taxJurisName = JsonUtil.getString(jsonObj, "tax_juris_name"); - obj.taxJurisCode = JsonUtil.getString(json, "tax_juris_code"); + obj.taxJurisCode = JsonUtil.getString(jsonObj, "tax_juris_code"); - obj.taxAmountInLocalCurrency = JsonUtil.getLong(json, "tax_amount_in_local_currency"); + obj.taxAmountInLocalCurrency = JsonUtil.getLong(jsonObj, "tax_amount_in_local_currency"); - obj.localCurrencyCode = JsonUtil.getString(json, "local_currency_code"); + obj.localCurrencyCode = JsonUtil.getString(jsonObj, "local_currency_code"); return obj; } @@ -2002,38 +1978,42 @@ public static ValidationStatus fromString(String value) { } public static LineItemAddresses fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static LineItemAddresses fromJson(JsonObject jsonObj) { LineItemAddresses obj = new LineItemAddresses(); - obj.lineItemId = JsonUtil.getString(json, "line_item_id"); + obj.lineItemId = JsonUtil.getString(jsonObj, "line_item_id"); - obj.firstName = JsonUtil.getString(json, "first_name"); + obj.firstName = JsonUtil.getString(jsonObj, "first_name"); - obj.lastName = JsonUtil.getString(json, "last_name"); + obj.lastName = JsonUtil.getString(jsonObj, "last_name"); - obj.email = JsonUtil.getString(json, "email"); + obj.email = JsonUtil.getString(jsonObj, "email"); - obj.company = JsonUtil.getString(json, "company"); + obj.company = JsonUtil.getString(jsonObj, "company"); - obj.phone = JsonUtil.getString(json, "phone"); + obj.phone = JsonUtil.getString(jsonObj, "phone"); - obj.line1 = JsonUtil.getString(json, "line1"); + obj.line1 = JsonUtil.getString(jsonObj, "line1"); - obj.line2 = JsonUtil.getString(json, "line2"); + obj.line2 = JsonUtil.getString(jsonObj, "line2"); - obj.line3 = JsonUtil.getString(json, "line3"); + obj.line3 = JsonUtil.getString(jsonObj, "line3"); - obj.city = JsonUtil.getString(json, "city"); + obj.city = JsonUtil.getString(jsonObj, "city"); - obj.stateCode = JsonUtil.getString(json, "state_code"); + obj.stateCode = JsonUtil.getString(jsonObj, "state_code"); - obj.state = JsonUtil.getString(json, "state"); + obj.state = JsonUtil.getString(jsonObj, "state"); - obj.country = JsonUtil.getString(json, "country"); + obj.country = JsonUtil.getString(jsonObj, "country"); - obj.zip = JsonUtil.getString(json, "zip"); + obj.zip = JsonUtil.getString(jsonObj, "zip"); obj.validationStatus = - ValidationStatus.fromString(JsonUtil.getString(json, "validation_status")); + ValidationStatus.fromString(JsonUtil.getString(jsonObj, "validation_status")); return obj; } @@ -2222,21 +2202,25 @@ public static DiscountType fromString(String value) { } public static Discounts fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Discounts fromJson(JsonObject jsonObj) { Discounts obj = new Discounts(); - obj.amount = JsonUtil.getLong(json, "amount"); + obj.amount = JsonUtil.getLong(jsonObj, "amount"); - obj.description = JsonUtil.getString(json, "description"); + obj.description = JsonUtil.getString(jsonObj, "description"); - obj.lineItemId = JsonUtil.getString(json, "line_item_id"); + obj.lineItemId = JsonUtil.getString(jsonObj, "line_item_id"); - obj.entityType = EntityType.fromString(JsonUtil.getString(json, "entity_type")); + obj.entityType = EntityType.fromString(JsonUtil.getString(jsonObj, "entity_type")); - obj.discountType = DiscountType.fromString(JsonUtil.getString(json, "discount_type")); + obj.discountType = DiscountType.fromString(JsonUtil.getString(jsonObj, "discount_type")); - obj.entityId = JsonUtil.getString(json, "entity_id"); + obj.entityId = JsonUtil.getString(jsonObj, "entity_id"); - obj.couponSetCode = JsonUtil.getString(json, "coupon_set_code"); + obj.couponSetCode = JsonUtil.getString(jsonObj, "coupon_set_code"); return obj; } @@ -2303,13 +2287,17 @@ public String getDescription() { } public static Taxes fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Taxes fromJson(JsonObject jsonObj) { Taxes obj = new Taxes(); - obj.name = JsonUtil.getString(json, "name"); + obj.name = JsonUtil.getString(jsonObj, "name"); - obj.amount = JsonUtil.getLong(json, "amount"); + obj.amount = JsonUtil.getLong(jsonObj, "amount"); - obj.description = JsonUtil.getString(json, "description"); + obj.description = JsonUtil.getString(jsonObj, "description"); return obj; } @@ -2358,11 +2346,15 @@ public String getRegistrationNumber() { } public static TaxOrigin fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static TaxOrigin fromJson(JsonObject jsonObj) { TaxOrigin obj = new TaxOrigin(); - obj.country = JsonUtil.getString(json, "country"); + obj.country = JsonUtil.getString(jsonObj, "country"); - obj.registrationNumber = JsonUtil.getString(json, "registration_number"); + obj.registrationNumber = JsonUtil.getString(jsonObj, "registration_number"); return obj; } @@ -2471,21 +2463,25 @@ public static TxnStatus fromString(String value) { } public static LinkedRefunds fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static LinkedRefunds fromJson(JsonObject jsonObj) { LinkedRefunds obj = new LinkedRefunds(); - obj.txnId = JsonUtil.getString(json, "txn_id"); + obj.txnId = JsonUtil.getString(jsonObj, "txn_id"); - obj.appliedAmount = JsonUtil.getLong(json, "applied_amount"); + obj.appliedAmount = JsonUtil.getLong(jsonObj, "applied_amount"); - obj.appliedAt = JsonUtil.getTimestamp(json, "applied_at"); + obj.appliedAt = JsonUtil.getTimestamp(jsonObj, "applied_at"); - obj.txnStatus = TxnStatus.fromString(JsonUtil.getString(json, "txn_status")); + obj.txnStatus = TxnStatus.fromString(JsonUtil.getString(jsonObj, "txn_status")); - obj.txnDate = JsonUtil.getTimestamp(json, "txn_date"); + obj.txnDate = JsonUtil.getTimestamp(jsonObj, "txn_date"); - obj.txnAmount = JsonUtil.getLong(json, "txn_amount"); + obj.txnAmount = JsonUtil.getLong(jsonObj, "txn_amount"); - obj.refundReasonCode = JsonUtil.getString(json, "refund_reason_code"); + obj.refundReasonCode = JsonUtil.getString(jsonObj, "refund_reason_code"); return obj; } @@ -2631,19 +2627,24 @@ public static TaxApplication fromString(String value) { } public static Allocations fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Allocations fromJson(JsonObject jsonObj) { Allocations obj = new Allocations(); - obj.invoiceId = JsonUtil.getString(json, "invoice_id"); + obj.invoiceId = JsonUtil.getString(jsonObj, "invoice_id"); - obj.allocatedAmount = JsonUtil.getLong(json, "allocated_amount"); + obj.allocatedAmount = JsonUtil.getLong(jsonObj, "allocated_amount"); - obj.allocatedAt = JsonUtil.getTimestamp(json, "allocated_at"); + obj.allocatedAt = JsonUtil.getTimestamp(jsonObj, "allocated_at"); - obj.invoiceDate = JsonUtil.getTimestamp(json, "invoice_date"); + obj.invoiceDate = JsonUtil.getTimestamp(jsonObj, "invoice_date"); - obj.invoiceStatus = InvoiceStatus.fromString(JsonUtil.getString(json, "invoice_status")); + obj.invoiceStatus = InvoiceStatus.fromString(JsonUtil.getString(jsonObj, "invoice_status")); - obj.taxApplication = TaxApplication.fromString(JsonUtil.getString(json, "tax_application")); + obj.taxApplication = + TaxApplication.fromString(JsonUtil.getString(jsonObj, "tax_application")); return obj; } @@ -2794,36 +2795,40 @@ public static ValidationStatus fromString(String value) { } public static ShippingAddress fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static ShippingAddress fromJson(JsonObject jsonObj) { ShippingAddress obj = new ShippingAddress(); - obj.firstName = JsonUtil.getString(json, "first_name"); + obj.firstName = JsonUtil.getString(jsonObj, "first_name"); - obj.lastName = JsonUtil.getString(json, "last_name"); + obj.lastName = JsonUtil.getString(jsonObj, "last_name"); - obj.email = JsonUtil.getString(json, "email"); + obj.email = JsonUtil.getString(jsonObj, "email"); - obj.company = JsonUtil.getString(json, "company"); + obj.company = JsonUtil.getString(jsonObj, "company"); - obj.phone = JsonUtil.getString(json, "phone"); + obj.phone = JsonUtil.getString(jsonObj, "phone"); - obj.line1 = JsonUtil.getString(json, "line1"); + obj.line1 = JsonUtil.getString(jsonObj, "line1"); - obj.line2 = JsonUtil.getString(json, "line2"); + obj.line2 = JsonUtil.getString(jsonObj, "line2"); - obj.line3 = JsonUtil.getString(json, "line3"); + obj.line3 = JsonUtil.getString(jsonObj, "line3"); - obj.city = JsonUtil.getString(json, "city"); + obj.city = JsonUtil.getString(jsonObj, "city"); - obj.stateCode = JsonUtil.getString(json, "state_code"); + obj.stateCode = JsonUtil.getString(jsonObj, "state_code"); - obj.state = JsonUtil.getString(json, "state"); + obj.state = JsonUtil.getString(jsonObj, "state"); - obj.country = JsonUtil.getString(json, "country"); + obj.country = JsonUtil.getString(jsonObj, "country"); - obj.zip = JsonUtil.getString(json, "zip"); + obj.zip = JsonUtil.getString(jsonObj, "zip"); obj.validationStatus = - ValidationStatus.fromString(JsonUtil.getString(json, "validation_status")); + ValidationStatus.fromString(JsonUtil.getString(jsonObj, "validation_status")); return obj; } @@ -3011,36 +3016,40 @@ public static ValidationStatus fromString(String value) { } public static BillingAddress fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static BillingAddress fromJson(JsonObject jsonObj) { BillingAddress obj = new BillingAddress(); - obj.firstName = JsonUtil.getString(json, "first_name"); + obj.firstName = JsonUtil.getString(jsonObj, "first_name"); - obj.lastName = JsonUtil.getString(json, "last_name"); + obj.lastName = JsonUtil.getString(jsonObj, "last_name"); - obj.email = JsonUtil.getString(json, "email"); + obj.email = JsonUtil.getString(jsonObj, "email"); - obj.company = JsonUtil.getString(json, "company"); + obj.company = JsonUtil.getString(jsonObj, "company"); - obj.phone = JsonUtil.getString(json, "phone"); + obj.phone = JsonUtil.getString(jsonObj, "phone"); - obj.line1 = JsonUtil.getString(json, "line1"); + obj.line1 = JsonUtil.getString(jsonObj, "line1"); - obj.line2 = JsonUtil.getString(json, "line2"); + obj.line2 = JsonUtil.getString(jsonObj, "line2"); - obj.line3 = JsonUtil.getString(json, "line3"); + obj.line3 = JsonUtil.getString(jsonObj, "line3"); - obj.city = JsonUtil.getString(json, "city"); + obj.city = JsonUtil.getString(jsonObj, "city"); - obj.stateCode = JsonUtil.getString(json, "state_code"); + obj.stateCode = JsonUtil.getString(jsonObj, "state_code"); - obj.state = JsonUtil.getString(json, "state"); + obj.state = JsonUtil.getString(jsonObj, "state"); - obj.country = JsonUtil.getString(json, "country"); + obj.country = JsonUtil.getString(jsonObj, "country"); - obj.zip = JsonUtil.getString(json, "zip"); + obj.zip = JsonUtil.getString(jsonObj, "zip"); obj.validationStatus = - ValidationStatus.fromString(JsonUtil.getString(json, "validation_status")); + ValidationStatus.fromString(JsonUtil.getString(jsonObj, "validation_status")); return obj; } @@ -3196,15 +3205,19 @@ public static Status fromString(String value) { } public static Einvoice fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Einvoice fromJson(JsonObject jsonObj) { Einvoice obj = new Einvoice(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.referenceNumber = JsonUtil.getString(json, "reference_number"); + obj.referenceNumber = JsonUtil.getString(jsonObj, "reference_number"); - obj.status = Status.fromString(JsonUtil.getString(json, "status")); + obj.status = Status.fromString(JsonUtil.getString(jsonObj, "status")); - obj.message = JsonUtil.getString(json, "message"); + obj.message = JsonUtil.getString(jsonObj, "message"); return obj; } @@ -3256,14 +3269,18 @@ public java.util.Map getOrganizationAddress() { } public static SiteDetailsAtCreation fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static SiteDetailsAtCreation fromJson(JsonObject jsonObj) { SiteDetailsAtCreation obj = new SiteDetailsAtCreation(); - obj.timezone = JsonUtil.getString(json, "timezone"); + obj.timezone = JsonUtil.getString(jsonObj, "timezone"); - String __organizationAddressJson = JsonUtil.getObject(json, "organization_address"); + JsonObject __organizationAddressObj = JsonUtil.getJsonObject(jsonObj, "organization_address"); obj.organizationAddress = - __organizationAddressJson != null - ? JsonUtil.parseJsonObjectToMap(__organizationAddressJson) + __organizationAddressObj != null + ? JsonUtil.parseJsonObjectToMap(__organizationAddressObj) : new java.util.HashMap<>(); return obj; diff --git a/src/main/java/com/chargebee/v4/models/creditNote/responses/CreditNoteCreateResponse.java b/src/main/java/com/chargebee/v4/models/creditNote/responses/CreditNoteCreateResponse.java index ddf2c0aa..96e57030 100644 --- a/src/main/java/com/chargebee/v4/models/creditNote/responses/CreditNoteCreateResponse.java +++ b/src/main/java/com/chargebee/v4/models/creditNote/responses/CreditNoteCreateResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -33,16 +34,17 @@ public static CreditNoteCreateResponse fromJson(String json) { /** Parse JSON response into CreditNoteCreateResponse object with HTTP response. */ public static CreditNoteCreateResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __creditNoteJson = JsonUtil.getObject(json, "credit_note"); - if (__creditNoteJson != null) { - builder.creditNote(CreditNote.fromJson(__creditNoteJson)); + JsonObject __creditNoteObj = JsonUtil.getJsonObject(jsonObj, "credit_note"); + if (__creditNoteObj != null) { + builder.creditNote(CreditNote.fromJson(__creditNoteObj)); } - String __invoiceJson = JsonUtil.getObject(json, "invoice"); - if (__invoiceJson != null) { - builder.invoice(Invoice.fromJson(__invoiceJson)); + JsonObject __invoiceObj = JsonUtil.getJsonObject(jsonObj, "invoice"); + if (__invoiceObj != null) { + builder.invoice(Invoice.fromJson(__invoiceObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/creditNote/responses/CreditNoteDeleteResponse.java b/src/main/java/com/chargebee/v4/models/creditNote/responses/CreditNoteDeleteResponse.java index 74b98a1f..98852bb5 100644 --- a/src/main/java/com/chargebee/v4/models/creditNote/responses/CreditNoteDeleteResponse.java +++ b/src/main/java/com/chargebee/v4/models/creditNote/responses/CreditNoteDeleteResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static CreditNoteDeleteResponse fromJson(String json) { /** Parse JSON response into CreditNoteDeleteResponse object with HTTP response. */ public static CreditNoteDeleteResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __creditNoteJson = JsonUtil.getObject(json, "credit_note"); - if (__creditNoteJson != null) { - builder.creditNote(CreditNote.fromJson(__creditNoteJson)); + JsonObject __creditNoteObj = JsonUtil.getJsonObject(jsonObj, "credit_note"); + if (__creditNoteObj != null) { + builder.creditNote(CreditNote.fromJson(__creditNoteObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/creditNote/responses/CreditNoteDownloadEinvoiceResponse.java b/src/main/java/com/chargebee/v4/models/creditNote/responses/CreditNoteDownloadEinvoiceResponse.java index a90ae049..d0b4611e 100644 --- a/src/main/java/com/chargebee/v4/models/creditNote/responses/CreditNoteDownloadEinvoiceResponse.java +++ b/src/main/java/com/chargebee/v4/models/creditNote/responses/CreditNoteDownloadEinvoiceResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; import java.util.List; @@ -28,15 +29,11 @@ public static CreditNoteDownloadEinvoiceResponse fromJson(String json) { /** Parse JSON response into CreditNoteDownloadEinvoiceResponse object with HTTP response. */ public static CreditNoteDownloadEinvoiceResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __downloadsJson = JsonUtil.getArray(json, "downloads"); - if (__downloadsJson != null) { - builder.downloads( - JsonUtil.parseObjectArray(__downloadsJson).stream() - .map(Download::fromJson) - .collect(java.util.stream.Collectors.toList())); - } + builder.downloads( + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "downloads"), Download::fromJson)); builder.httpResponse(httpResponse); return builder.build(); diff --git a/src/main/java/com/chargebee/v4/models/creditNote/responses/CreditNoteListResponse.java b/src/main/java/com/chargebee/v4/models/creditNote/responses/CreditNoteListResponse.java index 084d91de..a6764aa9 100644 --- a/src/main/java/com/chargebee/v4/models/creditNote/responses/CreditNoteListResponse.java +++ b/src/main/java/com/chargebee/v4/models/creditNote/responses/CreditNoteListResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.exceptions.ChargebeeException; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; import com.chargebee.v4.services.CreditNoteService; import com.chargebee.v4.models.creditNote.params.CreditNoteListParams; @@ -43,13 +44,12 @@ private CreditNoteListResponse( */ public static CreditNoteListResponse fromJson(String json) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(CreditNoteListItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "list"), CreditNoteListItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new CreditNoteListResponse(list, nextOffset, null, null, null); } catch (Exception e) { @@ -67,13 +67,12 @@ public static CreditNoteListResponse fromJson( CreditNoteListParams originalParams, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(CreditNoteListItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "list"), CreditNoteListItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new CreditNoteListResponse(list, nextOffset, service, originalParams, httpResponse); } catch (Exception e) { @@ -173,11 +172,15 @@ public CreditNote getCreditNote() { } public static CreditNoteListItem fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static CreditNoteListItem fromJson(JsonObject jsonObj) { CreditNoteListItem item = new CreditNoteListItem(); - String __creditNoteJson = JsonUtil.getObject(json, "credit_note"); - if (__creditNoteJson != null) { - item.creditNote = CreditNote.fromJson(__creditNoteJson); + JsonObject __creditNoteObj = JsonUtil.getJsonObject(jsonObj, "credit_note"); + if (__creditNoteObj != null) { + item.creditNote = CreditNote.fromJson(__creditNoteObj); } return item; diff --git a/src/main/java/com/chargebee/v4/models/creditNote/responses/CreditNotePdfResponse.java b/src/main/java/com/chargebee/v4/models/creditNote/responses/CreditNotePdfResponse.java index 019caef5..587a5769 100644 --- a/src/main/java/com/chargebee/v4/models/creditNote/responses/CreditNotePdfResponse.java +++ b/src/main/java/com/chargebee/v4/models/creditNote/responses/CreditNotePdfResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -26,11 +27,12 @@ public static CreditNotePdfResponse fromJson(String json) { /** Parse JSON response into CreditNotePdfResponse object with HTTP response. */ public static CreditNotePdfResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __downloadJson = JsonUtil.getObject(json, "download"); - if (__downloadJson != null) { - builder.download(Download.fromJson(__downloadJson)); + JsonObject __downloadObj = JsonUtil.getJsonObject(jsonObj, "download"); + if (__downloadObj != null) { + builder.download(Download.fromJson(__downloadObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/creditNote/responses/CreditNoteRecordRefundResponse.java b/src/main/java/com/chargebee/v4/models/creditNote/responses/CreditNoteRecordRefundResponse.java index 95fb2aa8..14145e70 100644 --- a/src/main/java/com/chargebee/v4/models/creditNote/responses/CreditNoteRecordRefundResponse.java +++ b/src/main/java/com/chargebee/v4/models/creditNote/responses/CreditNoteRecordRefundResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -33,16 +34,17 @@ public static CreditNoteRecordRefundResponse fromJson(String json) { /** Parse JSON response into CreditNoteRecordRefundResponse object with HTTP response. */ public static CreditNoteRecordRefundResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __creditNoteJson = JsonUtil.getObject(json, "credit_note"); - if (__creditNoteJson != null) { - builder.creditNote(CreditNote.fromJson(__creditNoteJson)); + JsonObject __creditNoteObj = JsonUtil.getJsonObject(jsonObj, "credit_note"); + if (__creditNoteObj != null) { + builder.creditNote(CreditNote.fromJson(__creditNoteObj)); } - String __transactionJson = JsonUtil.getObject(json, "transaction"); - if (__transactionJson != null) { - builder.transaction(Transaction.fromJson(__transactionJson)); + JsonObject __transactionObj = JsonUtil.getJsonObject(jsonObj, "transaction"); + if (__transactionObj != null) { + builder.transaction(Transaction.fromJson(__transactionObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/creditNote/responses/CreditNoteRefundResponse.java b/src/main/java/com/chargebee/v4/models/creditNote/responses/CreditNoteRefundResponse.java index dcf0ce6e..c74cf2ca 100644 --- a/src/main/java/com/chargebee/v4/models/creditNote/responses/CreditNoteRefundResponse.java +++ b/src/main/java/com/chargebee/v4/models/creditNote/responses/CreditNoteRefundResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -33,16 +34,17 @@ public static CreditNoteRefundResponse fromJson(String json) { /** Parse JSON response into CreditNoteRefundResponse object with HTTP response. */ public static CreditNoteRefundResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __creditNoteJson = JsonUtil.getObject(json, "credit_note"); - if (__creditNoteJson != null) { - builder.creditNote(CreditNote.fromJson(__creditNoteJson)); + JsonObject __creditNoteObj = JsonUtil.getJsonObject(jsonObj, "credit_note"); + if (__creditNoteObj != null) { + builder.creditNote(CreditNote.fromJson(__creditNoteObj)); } - String __transactionJson = JsonUtil.getObject(json, "transaction"); - if (__transactionJson != null) { - builder.transaction(Transaction.fromJson(__transactionJson)); + JsonObject __transactionObj = JsonUtil.getJsonObject(jsonObj, "transaction"); + if (__transactionObj != null) { + builder.transaction(Transaction.fromJson(__transactionObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/creditNote/responses/CreditNoteRemoveTaxWithheldRefundResponse.java b/src/main/java/com/chargebee/v4/models/creditNote/responses/CreditNoteRemoveTaxWithheldRefundResponse.java index d62bb9c9..fa5134f3 100644 --- a/src/main/java/com/chargebee/v4/models/creditNote/responses/CreditNoteRemoveTaxWithheldRefundResponse.java +++ b/src/main/java/com/chargebee/v4/models/creditNote/responses/CreditNoteRemoveTaxWithheldRefundResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -30,11 +31,12 @@ public static CreditNoteRemoveTaxWithheldRefundResponse fromJson(String json) { public static CreditNoteRemoveTaxWithheldRefundResponse fromJson( String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __creditNoteJson = JsonUtil.getObject(json, "credit_note"); - if (__creditNoteJson != null) { - builder.creditNote(CreditNote.fromJson(__creditNoteJson)); + JsonObject __creditNoteObj = JsonUtil.getJsonObject(jsonObj, "credit_note"); + if (__creditNoteObj != null) { + builder.creditNote(CreditNote.fromJson(__creditNoteObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/creditNote/responses/CreditNoteResendEinvoiceResponse.java b/src/main/java/com/chargebee/v4/models/creditNote/responses/CreditNoteResendEinvoiceResponse.java index fb09ec80..7cad2317 100644 --- a/src/main/java/com/chargebee/v4/models/creditNote/responses/CreditNoteResendEinvoiceResponse.java +++ b/src/main/java/com/chargebee/v4/models/creditNote/responses/CreditNoteResendEinvoiceResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static CreditNoteResendEinvoiceResponse fromJson(String json) { /** Parse JSON response into CreditNoteResendEinvoiceResponse object with HTTP response. */ public static CreditNoteResendEinvoiceResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __creditNoteJson = JsonUtil.getObject(json, "credit_note"); - if (__creditNoteJson != null) { - builder.creditNote(CreditNote.fromJson(__creditNoteJson)); + JsonObject __creditNoteObj = JsonUtil.getJsonObject(jsonObj, "credit_note"); + if (__creditNoteObj != null) { + builder.creditNote(CreditNote.fromJson(__creditNoteObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/creditNote/responses/CreditNoteRetrieveResponse.java b/src/main/java/com/chargebee/v4/models/creditNote/responses/CreditNoteRetrieveResponse.java index 3bf8a70b..8569ccfe 100644 --- a/src/main/java/com/chargebee/v4/models/creditNote/responses/CreditNoteRetrieveResponse.java +++ b/src/main/java/com/chargebee/v4/models/creditNote/responses/CreditNoteRetrieveResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static CreditNoteRetrieveResponse fromJson(String json) { /** Parse JSON response into CreditNoteRetrieveResponse object with HTTP response. */ public static CreditNoteRetrieveResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __creditNoteJson = JsonUtil.getObject(json, "credit_note"); - if (__creditNoteJson != null) { - builder.creditNote(CreditNote.fromJson(__creditNoteJson)); + JsonObject __creditNoteObj = JsonUtil.getJsonObject(jsonObj, "credit_note"); + if (__creditNoteObj != null) { + builder.creditNote(CreditNote.fromJson(__creditNoteObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/creditNote/responses/CreditNoteSendEinvoiceResponse.java b/src/main/java/com/chargebee/v4/models/creditNote/responses/CreditNoteSendEinvoiceResponse.java index 24dcd675..37d27285 100644 --- a/src/main/java/com/chargebee/v4/models/creditNote/responses/CreditNoteSendEinvoiceResponse.java +++ b/src/main/java/com/chargebee/v4/models/creditNote/responses/CreditNoteSendEinvoiceResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static CreditNoteSendEinvoiceResponse fromJson(String json) { /** Parse JSON response into CreditNoteSendEinvoiceResponse object with HTTP response. */ public static CreditNoteSendEinvoiceResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __creditNoteJson = JsonUtil.getObject(json, "credit_note"); - if (__creditNoteJson != null) { - builder.creditNote(CreditNote.fromJson(__creditNoteJson)); + JsonObject __creditNoteObj = JsonUtil.getJsonObject(jsonObj, "credit_note"); + if (__creditNoteObj != null) { + builder.creditNote(CreditNote.fromJson(__creditNoteObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/creditNote/responses/CreditNotesForCustomerResponse.java b/src/main/java/com/chargebee/v4/models/creditNote/responses/CreditNotesForCustomerResponse.java index 67d17215..001329a8 100644 --- a/src/main/java/com/chargebee/v4/models/creditNote/responses/CreditNotesForCustomerResponse.java +++ b/src/main/java/com/chargebee/v4/models/creditNote/responses/CreditNotesForCustomerResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.exceptions.ChargebeeException; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; import com.chargebee.v4.services.CreditNoteService; import com.chargebee.v4.models.creditNote.params.CreditNotesForCustomerParams; @@ -48,13 +49,14 @@ private CreditNotesForCustomerResponse( */ public static CreditNotesForCustomerResponse fromJson(String json) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(CreditNoteCreditNotesForCustomerItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "list"), + CreditNoteCreditNotesForCustomerItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new CreditNotesForCustomerResponse(list, nextOffset, null, null, null, null); } catch (Exception e) { @@ -73,13 +75,14 @@ public static CreditNotesForCustomerResponse fromJson( String customerId, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(CreditNoteCreditNotesForCustomerItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "list"), + CreditNoteCreditNotesForCustomerItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new CreditNotesForCustomerResponse( list, nextOffset, customerId, service, originalParams, httpResponse); @@ -182,11 +185,15 @@ public CreditNote getCreditNote() { } public static CreditNoteCreditNotesForCustomerItem fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static CreditNoteCreditNotesForCustomerItem fromJson(JsonObject jsonObj) { CreditNoteCreditNotesForCustomerItem item = new CreditNoteCreditNotesForCustomerItem(); - String __creditNoteJson = JsonUtil.getObject(json, "credit_note"); - if (__creditNoteJson != null) { - item.creditNote = CreditNote.fromJson(__creditNoteJson); + JsonObject __creditNoteObj = JsonUtil.getJsonObject(jsonObj, "credit_note"); + if (__creditNoteObj != null) { + item.creditNote = CreditNote.fromJson(__creditNoteObj); } return item; diff --git a/src/main/java/com/chargebee/v4/models/creditNote/responses/ImportCreditNoteResponse.java b/src/main/java/com/chargebee/v4/models/creditNote/responses/ImportCreditNoteResponse.java index 8889fb81..463541d6 100644 --- a/src/main/java/com/chargebee/v4/models/creditNote/responses/ImportCreditNoteResponse.java +++ b/src/main/java/com/chargebee/v4/models/creditNote/responses/ImportCreditNoteResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static ImportCreditNoteResponse fromJson(String json) { /** Parse JSON response into ImportCreditNoteResponse object with HTTP response. */ public static ImportCreditNoteResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __creditNoteJson = JsonUtil.getObject(json, "credit_note"); - if (__creditNoteJson != null) { - builder.creditNote(CreditNote.fromJson(__creditNoteJson)); + JsonObject __creditNoteObj = JsonUtil.getJsonObject(jsonObj, "credit_note"); + if (__creditNoteObj != null) { + builder.creditNote(CreditNote.fromJson(__creditNoteObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/creditNote/responses/VoidCreditNoteResponse.java b/src/main/java/com/chargebee/v4/models/creditNote/responses/VoidCreditNoteResponse.java index 359dcde3..6f0ced69 100644 --- a/src/main/java/com/chargebee/v4/models/creditNote/responses/VoidCreditNoteResponse.java +++ b/src/main/java/com/chargebee/v4/models/creditNote/responses/VoidCreditNoteResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -26,11 +27,12 @@ public static VoidCreditNoteResponse fromJson(String json) { /** Parse JSON response into VoidCreditNoteResponse object with HTTP response. */ public static VoidCreditNoteResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __creditNoteJson = JsonUtil.getObject(json, "credit_note"); - if (__creditNoteJson != null) { - builder.creditNote(CreditNote.fromJson(__creditNoteJson)); + JsonObject __creditNoteObj = JsonUtil.getJsonObject(jsonObj, "credit_note"); + if (__creditNoteObj != null) { + builder.creditNote(CreditNote.fromJson(__creditNoteObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/creditNoteEstimate/CreditNoteEstimate.java b/src/main/java/com/chargebee/v4/models/creditNoteEstimate/CreditNoteEstimate.java index fc29901c..9d896aea 100644 --- a/src/main/java/com/chargebee/v4/models/creditNoteEstimate/CreditNoteEstimate.java +++ b/src/main/java/com/chargebee/v4/models/creditNoteEstimate/CreditNoteEstimate.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.creditNoteEstimate; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import java.math.BigDecimal; import java.sql.Timestamp; import java.util.List; @@ -154,57 +155,51 @@ public static PriceType fromString(String value) { } public static CreditNoteEstimate fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static CreditNoteEstimate fromJson(JsonObject jsonObj) { CreditNoteEstimate obj = new CreditNoteEstimate(); - obj.referenceInvoiceId = JsonUtil.getString(json, "reference_invoice_id"); + obj.referenceInvoiceId = JsonUtil.getString(jsonObj, "reference_invoice_id"); - obj.type = Type.fromString(JsonUtil.getString(json, "type")); + obj.type = Type.fromString(JsonUtil.getString(jsonObj, "type")); - obj.priceType = PriceType.fromString(JsonUtil.getString(json, "price_type")); + obj.priceType = PriceType.fromString(JsonUtil.getString(jsonObj, "price_type")); - obj.currencyCode = JsonUtil.getString(json, "currency_code"); + obj.currencyCode = JsonUtil.getString(jsonObj, "currency_code"); - obj.subTotal = JsonUtil.getLong(json, "sub_total"); + obj.subTotal = JsonUtil.getLong(jsonObj, "sub_total"); - obj.total = JsonUtil.getLong(json, "total"); + obj.total = JsonUtil.getLong(jsonObj, "total"); - obj.amountAllocated = JsonUtil.getLong(json, "amount_allocated"); + obj.amountAllocated = JsonUtil.getLong(jsonObj, "amount_allocated"); - obj.amountAvailable = JsonUtil.getLong(json, "amount_available"); + obj.amountAvailable = JsonUtil.getLong(jsonObj, "amount_available"); - obj.roundOffAmount = JsonUtil.getLong(json, "round_off_amount"); + obj.roundOffAmount = JsonUtil.getLong(jsonObj, "round_off_amount"); - obj.customerId = JsonUtil.getString(json, "customer_id"); + obj.customerId = JsonUtil.getString(jsonObj, "customer_id"); obj.lineItems = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "line_items")).stream() - .map(LineItems::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "line_items"), LineItems::fromJson); obj.lineItemTiers = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "line_item_tiers")).stream() - .map(LineItemTiers::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "line_item_tiers"), LineItemTiers::fromJson); obj.lineItemDiscounts = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "line_item_discounts")).stream() - .map(LineItemDiscounts::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "line_item_discounts"), LineItemDiscounts::fromJson); obj.lineItemTaxes = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "line_item_taxes")).stream() - .map(LineItemTaxes::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "line_item_taxes"), LineItemTaxes::fromJson); obj.discounts = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "discounts")).stream() - .map(Discounts::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "discounts"), Discounts::fromJson); - obj.taxes = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "taxes")).stream() - .map(Taxes::fromJson) - .collect(java.util.stream.Collectors.toList()); + obj.taxes = JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "taxes"), Taxes::fromJson); return obj; } @@ -538,58 +533,62 @@ public static TaxExemptReason fromString(String value) { } public static LineItems fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static LineItems fromJson(JsonObject jsonObj) { LineItems obj = new LineItems(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.subscriptionId = JsonUtil.getString(json, "subscription_id"); + obj.subscriptionId = JsonUtil.getString(jsonObj, "subscription_id"); - obj.dateFrom = JsonUtil.getTimestamp(json, "date_from"); + obj.dateFrom = JsonUtil.getTimestamp(jsonObj, "date_from"); - obj.dateTo = JsonUtil.getTimestamp(json, "date_to"); + obj.dateTo = JsonUtil.getTimestamp(jsonObj, "date_to"); - obj.unitAmount = JsonUtil.getLong(json, "unit_amount"); + obj.unitAmount = JsonUtil.getLong(jsonObj, "unit_amount"); - obj.quantity = JsonUtil.getInteger(json, "quantity"); + obj.quantity = JsonUtil.getInteger(jsonObj, "quantity"); - obj.amount = JsonUtil.getLong(json, "amount"); + obj.amount = JsonUtil.getLong(jsonObj, "amount"); - obj.pricingModel = PricingModel.fromString(JsonUtil.getString(json, "pricing_model")); + obj.pricingModel = PricingModel.fromString(JsonUtil.getString(jsonObj, "pricing_model")); - obj.isTaxed = JsonUtil.getBoolean(json, "is_taxed"); + obj.isTaxed = JsonUtil.getBoolean(jsonObj, "is_taxed"); - obj.taxAmount = JsonUtil.getLong(json, "tax_amount"); + obj.taxAmount = JsonUtil.getLong(jsonObj, "tax_amount"); - obj.taxRate = JsonUtil.getDouble(json, "tax_rate"); + obj.taxRate = JsonUtil.getDouble(jsonObj, "tax_rate"); - obj.unitAmountInDecimal = JsonUtil.getString(json, "unit_amount_in_decimal"); + obj.unitAmountInDecimal = JsonUtil.getString(jsonObj, "unit_amount_in_decimal"); - obj.quantityInDecimal = JsonUtil.getString(json, "quantity_in_decimal"); + obj.quantityInDecimal = JsonUtil.getString(jsonObj, "quantity_in_decimal"); - obj.amountInDecimal = JsonUtil.getString(json, "amount_in_decimal"); + obj.amountInDecimal = JsonUtil.getString(jsonObj, "amount_in_decimal"); - obj.discountAmount = JsonUtil.getLong(json, "discount_amount"); + obj.discountAmount = JsonUtil.getLong(jsonObj, "discount_amount"); - obj.itemLevelDiscountAmount = JsonUtil.getLong(json, "item_level_discount_amount"); + obj.itemLevelDiscountAmount = JsonUtil.getLong(jsonObj, "item_level_discount_amount"); - obj.metered = JsonUtil.getBoolean(json, "metered"); + obj.metered = JsonUtil.getBoolean(jsonObj, "metered"); - obj.isPercentagePricing = JsonUtil.getBoolean(json, "is_percentage_pricing"); + obj.isPercentagePricing = JsonUtil.getBoolean(jsonObj, "is_percentage_pricing"); - obj.referenceLineItemId = JsonUtil.getString(json, "reference_line_item_id"); + obj.referenceLineItemId = JsonUtil.getString(jsonObj, "reference_line_item_id"); - obj.description = JsonUtil.getString(json, "description"); + obj.description = JsonUtil.getString(jsonObj, "description"); - obj.entityDescription = JsonUtil.getString(json, "entity_description"); + obj.entityDescription = JsonUtil.getString(jsonObj, "entity_description"); - obj.entityType = EntityType.fromString(JsonUtil.getString(json, "entity_type")); + obj.entityType = EntityType.fromString(JsonUtil.getString(jsonObj, "entity_type")); obj.taxExemptReason = - TaxExemptReason.fromString(JsonUtil.getString(json, "tax_exempt_reason")); + TaxExemptReason.fromString(JsonUtil.getString(jsonObj, "tax_exempt_reason")); - obj.entityId = JsonUtil.getString(json, "entity_id"); + obj.entityId = JsonUtil.getString(jsonObj, "entity_id"); - obj.customerId = JsonUtil.getString(json, "customer_id"); + obj.customerId = JsonUtil.getString(jsonObj, "customer_id"); return obj; } @@ -804,29 +803,33 @@ public static PricingType fromString(String value) { } public static LineItemTiers fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static LineItemTiers fromJson(JsonObject jsonObj) { LineItemTiers obj = new LineItemTiers(); - obj.lineItemId = JsonUtil.getString(json, "line_item_id"); + obj.lineItemId = JsonUtil.getString(jsonObj, "line_item_id"); - obj.startingUnit = JsonUtil.getInteger(json, "starting_unit"); + obj.startingUnit = JsonUtil.getInteger(jsonObj, "starting_unit"); - obj.endingUnit = JsonUtil.getInteger(json, "ending_unit"); + obj.endingUnit = JsonUtil.getInteger(jsonObj, "ending_unit"); - obj.quantityUsed = JsonUtil.getInteger(json, "quantity_used"); + obj.quantityUsed = JsonUtil.getInteger(jsonObj, "quantity_used"); - obj.unitAmount = JsonUtil.getLong(json, "unit_amount"); + obj.unitAmount = JsonUtil.getLong(jsonObj, "unit_amount"); - obj.startingUnitInDecimal = JsonUtil.getString(json, "starting_unit_in_decimal"); + obj.startingUnitInDecimal = JsonUtil.getString(jsonObj, "starting_unit_in_decimal"); - obj.endingUnitInDecimal = JsonUtil.getString(json, "ending_unit_in_decimal"); + obj.endingUnitInDecimal = JsonUtil.getString(jsonObj, "ending_unit_in_decimal"); - obj.quantityUsedInDecimal = JsonUtil.getString(json, "quantity_used_in_decimal"); + obj.quantityUsedInDecimal = JsonUtil.getString(jsonObj, "quantity_used_in_decimal"); - obj.unitAmountInDecimal = JsonUtil.getString(json, "unit_amount_in_decimal"); + obj.unitAmountInDecimal = JsonUtil.getString(jsonObj, "unit_amount_in_decimal"); - obj.pricingType = PricingType.fromString(JsonUtil.getString(json, "pricing_type")); + obj.pricingType = PricingType.fromString(JsonUtil.getString(jsonObj, "pricing_type")); - obj.packageSize = JsonUtil.getInteger(json, "package_size"); + obj.packageSize = JsonUtil.getInteger(jsonObj, "package_size"); return obj; } @@ -961,17 +964,21 @@ public static DiscountType fromString(String value) { } public static LineItemDiscounts fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static LineItemDiscounts fromJson(JsonObject jsonObj) { LineItemDiscounts obj = new LineItemDiscounts(); - obj.lineItemId = JsonUtil.getString(json, "line_item_id"); + obj.lineItemId = JsonUtil.getString(jsonObj, "line_item_id"); - obj.discountType = DiscountType.fromString(JsonUtil.getString(json, "discount_type")); + obj.discountType = DiscountType.fromString(JsonUtil.getString(jsonObj, "discount_type")); - obj.couponId = JsonUtil.getString(json, "coupon_id"); + obj.couponId = JsonUtil.getString(jsonObj, "coupon_id"); - obj.entityId = JsonUtil.getString(json, "entity_id"); + obj.entityId = JsonUtil.getString(jsonObj, "entity_id"); - obj.discountAmount = JsonUtil.getLong(json, "discount_amount"); + obj.discountAmount = JsonUtil.getLong(jsonObj, "discount_amount"); return obj; } @@ -1131,37 +1138,41 @@ public static TaxJurisType fromString(String value) { } public static LineItemTaxes fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static LineItemTaxes fromJson(JsonObject jsonObj) { LineItemTaxes obj = new LineItemTaxes(); - obj.lineItemId = JsonUtil.getString(json, "line_item_id"); + obj.lineItemId = JsonUtil.getString(jsonObj, "line_item_id"); - obj.taxName = JsonUtil.getString(json, "tax_name"); + obj.taxName = JsonUtil.getString(jsonObj, "tax_name"); - obj.taxRate = JsonUtil.getDouble(json, "tax_rate"); + obj.taxRate = JsonUtil.getDouble(jsonObj, "tax_rate"); - obj.dateTo = JsonUtil.getTimestamp(json, "date_to"); + obj.dateTo = JsonUtil.getTimestamp(jsonObj, "date_to"); - obj.dateFrom = JsonUtil.getTimestamp(json, "date_from"); + obj.dateFrom = JsonUtil.getTimestamp(jsonObj, "date_from"); - obj.proratedTaxableAmount = JsonUtil.getBigDecimal(json, "prorated_taxable_amount"); + obj.proratedTaxableAmount = JsonUtil.getBigDecimal(jsonObj, "prorated_taxable_amount"); - obj.isPartialTaxApplied = JsonUtil.getBoolean(json, "is_partial_tax_applied"); + obj.isPartialTaxApplied = JsonUtil.getBoolean(jsonObj, "is_partial_tax_applied"); - obj.isNonComplianceTax = JsonUtil.getBoolean(json, "is_non_compliance_tax"); + obj.isNonComplianceTax = JsonUtil.getBoolean(jsonObj, "is_non_compliance_tax"); - obj.taxableAmount = JsonUtil.getLong(json, "taxable_amount"); + obj.taxableAmount = JsonUtil.getLong(jsonObj, "taxable_amount"); - obj.taxAmount = JsonUtil.getLong(json, "tax_amount"); + obj.taxAmount = JsonUtil.getLong(jsonObj, "tax_amount"); - obj.taxJurisType = TaxJurisType.fromString(JsonUtil.getString(json, "tax_juris_type")); + obj.taxJurisType = TaxJurisType.fromString(JsonUtil.getString(jsonObj, "tax_juris_type")); - obj.taxJurisName = JsonUtil.getString(json, "tax_juris_name"); + obj.taxJurisName = JsonUtil.getString(jsonObj, "tax_juris_name"); - obj.taxJurisCode = JsonUtil.getString(json, "tax_juris_code"); + obj.taxJurisCode = JsonUtil.getString(jsonObj, "tax_juris_code"); - obj.taxAmountInLocalCurrency = JsonUtil.getLong(json, "tax_amount_in_local_currency"); + obj.taxAmountInLocalCurrency = JsonUtil.getLong(jsonObj, "tax_amount_in_local_currency"); - obj.localCurrencyCode = JsonUtil.getString(json, "local_currency_code"); + obj.localCurrencyCode = JsonUtil.getString(jsonObj, "local_currency_code"); return obj; } @@ -1350,21 +1361,25 @@ public static DiscountType fromString(String value) { } public static Discounts fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Discounts fromJson(JsonObject jsonObj) { Discounts obj = new Discounts(); - obj.amount = JsonUtil.getLong(json, "amount"); + obj.amount = JsonUtil.getLong(jsonObj, "amount"); - obj.description = JsonUtil.getString(json, "description"); + obj.description = JsonUtil.getString(jsonObj, "description"); - obj.lineItemId = JsonUtil.getString(json, "line_item_id"); + obj.lineItemId = JsonUtil.getString(jsonObj, "line_item_id"); - obj.entityType = EntityType.fromString(JsonUtil.getString(json, "entity_type")); + obj.entityType = EntityType.fromString(JsonUtil.getString(jsonObj, "entity_type")); - obj.discountType = DiscountType.fromString(JsonUtil.getString(json, "discount_type")); + obj.discountType = DiscountType.fromString(JsonUtil.getString(jsonObj, "discount_type")); - obj.entityId = JsonUtil.getString(json, "entity_id"); + obj.entityId = JsonUtil.getString(jsonObj, "entity_id"); - obj.couponSetCode = JsonUtil.getString(json, "coupon_set_code"); + obj.couponSetCode = JsonUtil.getString(jsonObj, "coupon_set_code"); return obj; } @@ -1431,13 +1446,17 @@ public String getDescription() { } public static Taxes fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Taxes fromJson(JsonObject jsonObj) { Taxes obj = new Taxes(); - obj.name = JsonUtil.getString(json, "name"); + obj.name = JsonUtil.getString(jsonObj, "name"); - obj.amount = JsonUtil.getLong(json, "amount"); + obj.amount = JsonUtil.getLong(jsonObj, "amount"); - obj.description = JsonUtil.getString(json, "description"); + obj.description = JsonUtil.getString(jsonObj, "description"); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/csvTaxRule/responses/CsvTaxRuleCreateResponse.java b/src/main/java/com/chargebee/v4/models/csvTaxRule/responses/CsvTaxRuleCreateResponse.java index 3845c766..d4f1fce1 100644 --- a/src/main/java/com/chargebee/v4/models/csvTaxRule/responses/CsvTaxRuleCreateResponse.java +++ b/src/main/java/com/chargebee/v4/models/csvTaxRule/responses/CsvTaxRuleCreateResponse.java @@ -1,6 +1,8 @@ package com.chargebee.v4.models.csvTaxRule.responses; import com.chargebee.v4.models.BaseResponse; +import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -21,6 +23,7 @@ public static CsvTaxRuleCreateResponse fromJson(String json) { /** Parse JSON response into CsvTaxRuleCreateResponse object with HTTP response. */ public static CsvTaxRuleCreateResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/currency/Currency.java b/src/main/java/com/chargebee/v4/models/currency/Currency.java index 73202f10..ab46cd35 100644 --- a/src/main/java/com/chargebee/v4/models/currency/Currency.java +++ b/src/main/java/com/chargebee/v4/models/currency/Currency.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.currency; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; public class Currency { @@ -71,19 +72,23 @@ public static ForexType fromString(String value) { } public static Currency fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Currency fromJson(JsonObject jsonObj) { Currency obj = new Currency(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.enabled = JsonUtil.getBoolean(json, "enabled"); + obj.enabled = JsonUtil.getBoolean(jsonObj, "enabled"); - obj.forexType = ForexType.fromString(JsonUtil.getString(json, "forex_type")); + obj.forexType = ForexType.fromString(JsonUtil.getString(jsonObj, "forex_type")); - obj.currencyCode = JsonUtil.getString(json, "currency_code"); + obj.currencyCode = JsonUtil.getString(jsonObj, "currency_code"); - obj.isBaseCurrency = JsonUtil.getBoolean(json, "is_base_currency"); + obj.isBaseCurrency = JsonUtil.getBoolean(jsonObj, "is_base_currency"); - obj.manualExchangeRate = JsonUtil.getString(json, "manual_exchange_rate"); + obj.manualExchangeRate = JsonUtil.getString(jsonObj, "manual_exchange_rate"); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/currency/responses/CurrencyAddScheduleResponse.java b/src/main/java/com/chargebee/v4/models/currency/responses/CurrencyAddScheduleResponse.java index 3b4a8967..0a3344d7 100644 --- a/src/main/java/com/chargebee/v4/models/currency/responses/CurrencyAddScheduleResponse.java +++ b/src/main/java/com/chargebee/v4/models/currency/responses/CurrencyAddScheduleResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; import java.sql.Timestamp; @@ -32,13 +33,14 @@ public static CurrencyAddScheduleResponse fromJson(String json) { /** Parse JSON response into CurrencyAddScheduleResponse object with HTTP response. */ public static CurrencyAddScheduleResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - builder.scheduledAt(JsonUtil.getTimestamp(json, "scheduled_at")); + builder.scheduledAt(JsonUtil.getTimestamp(jsonObj, "scheduled_at")); - String __currencyJson = JsonUtil.getObject(json, "currency"); - if (__currencyJson != null) { - builder.currency(Currency.fromJson(__currencyJson)); + JsonObject __currencyObj = JsonUtil.getJsonObject(jsonObj, "currency"); + if (__currencyObj != null) { + builder.currency(Currency.fromJson(__currencyObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/currency/responses/CurrencyCreateResponse.java b/src/main/java/com/chargebee/v4/models/currency/responses/CurrencyCreateResponse.java index f5d80acb..3b616528 100644 --- a/src/main/java/com/chargebee/v4/models/currency/responses/CurrencyCreateResponse.java +++ b/src/main/java/com/chargebee/v4/models/currency/responses/CurrencyCreateResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -26,11 +27,12 @@ public static CurrencyCreateResponse fromJson(String json) { /** Parse JSON response into CurrencyCreateResponse object with HTTP response. */ public static CurrencyCreateResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __currencyJson = JsonUtil.getObject(json, "currency"); - if (__currencyJson != null) { - builder.currency(Currency.fromJson(__currencyJson)); + JsonObject __currencyObj = JsonUtil.getJsonObject(jsonObj, "currency"); + if (__currencyObj != null) { + builder.currency(Currency.fromJson(__currencyObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/currency/responses/CurrencyListResponse.java b/src/main/java/com/chargebee/v4/models/currency/responses/CurrencyListResponse.java index 0aa9a403..54691452 100644 --- a/src/main/java/com/chargebee/v4/models/currency/responses/CurrencyListResponse.java +++ b/src/main/java/com/chargebee/v4/models/currency/responses/CurrencyListResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.exceptions.ChargebeeException; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; import com.chargebee.v4.services.CurrencyService; import com.chargebee.v4.models.currency.params.CurrencyListParams; @@ -43,13 +44,12 @@ private CurrencyListResponse( */ public static CurrencyListResponse fromJson(String json) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(CurrencyListItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "list"), CurrencyListItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new CurrencyListResponse(list, nextOffset, null, null, null); } catch (Exception e) { @@ -67,13 +67,12 @@ public static CurrencyListResponse fromJson( CurrencyListParams originalParams, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(CurrencyListItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "list"), CurrencyListItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new CurrencyListResponse(list, nextOffset, service, originalParams, httpResponse); } catch (Exception e) { @@ -173,11 +172,15 @@ public Currency getCurrency() { } public static CurrencyListItem fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static CurrencyListItem fromJson(JsonObject jsonObj) { CurrencyListItem item = new CurrencyListItem(); - String __currencyJson = JsonUtil.getObject(json, "currency"); - if (__currencyJson != null) { - item.currency = Currency.fromJson(__currencyJson); + JsonObject __currencyObj = JsonUtil.getJsonObject(jsonObj, "currency"); + if (__currencyObj != null) { + item.currency = Currency.fromJson(__currencyObj); } return item; diff --git a/src/main/java/com/chargebee/v4/models/currency/responses/CurrencyRemoveScheduleResponse.java b/src/main/java/com/chargebee/v4/models/currency/responses/CurrencyRemoveScheduleResponse.java index 5096d863..38d0ecc3 100644 --- a/src/main/java/com/chargebee/v4/models/currency/responses/CurrencyRemoveScheduleResponse.java +++ b/src/main/java/com/chargebee/v4/models/currency/responses/CurrencyRemoveScheduleResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; import java.sql.Timestamp; @@ -32,13 +33,14 @@ public static CurrencyRemoveScheduleResponse fromJson(String json) { /** Parse JSON response into CurrencyRemoveScheduleResponse object with HTTP response. */ public static CurrencyRemoveScheduleResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - builder.scheduledAt(JsonUtil.getTimestamp(json, "scheduled_at")); + builder.scheduledAt(JsonUtil.getTimestamp(jsonObj, "scheduled_at")); - String __currencyJson = JsonUtil.getObject(json, "currency"); - if (__currencyJson != null) { - builder.currency(Currency.fromJson(__currencyJson)); + JsonObject __currencyObj = JsonUtil.getJsonObject(jsonObj, "currency"); + if (__currencyObj != null) { + builder.currency(Currency.fromJson(__currencyObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/currency/responses/CurrencyRetrieveResponse.java b/src/main/java/com/chargebee/v4/models/currency/responses/CurrencyRetrieveResponse.java index 9f4bdf44..817c3cda 100644 --- a/src/main/java/com/chargebee/v4/models/currency/responses/CurrencyRetrieveResponse.java +++ b/src/main/java/com/chargebee/v4/models/currency/responses/CurrencyRetrieveResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static CurrencyRetrieveResponse fromJson(String json) { /** Parse JSON response into CurrencyRetrieveResponse object with HTTP response. */ public static CurrencyRetrieveResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __currencyJson = JsonUtil.getObject(json, "currency"); - if (__currencyJson != null) { - builder.currency(Currency.fromJson(__currencyJson)); + JsonObject __currencyObj = JsonUtil.getJsonObject(jsonObj, "currency"); + if (__currencyObj != null) { + builder.currency(Currency.fromJson(__currencyObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/currency/responses/CurrencyUpdateResponse.java b/src/main/java/com/chargebee/v4/models/currency/responses/CurrencyUpdateResponse.java index e873fe5e..1c22b012 100644 --- a/src/main/java/com/chargebee/v4/models/currency/responses/CurrencyUpdateResponse.java +++ b/src/main/java/com/chargebee/v4/models/currency/responses/CurrencyUpdateResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -26,11 +27,12 @@ public static CurrencyUpdateResponse fromJson(String json) { /** Parse JSON response into CurrencyUpdateResponse object with HTTP response. */ public static CurrencyUpdateResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __currencyJson = JsonUtil.getObject(json, "currency"); - if (__currencyJson != null) { - builder.currency(Currency.fromJson(__currencyJson)); + JsonObject __currencyObj = JsonUtil.getJsonObject(jsonObj, "currency"); + if (__currencyObj != null) { + builder.currency(Currency.fromJson(__currencyObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/customer/Customer.java b/src/main/java/com/chargebee/v4/models/customer/Customer.java index ed8ef955..39b84545 100644 --- a/src/main/java/com/chargebee/v4/models/customer/Customer.java +++ b/src/main/java/com/chargebee/v4/models/customer/Customer.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.customer; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import java.sql.Timestamp; import java.util.List; @@ -890,9 +891,12 @@ public static CustomerType fromString(String value) { } public static Customer fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Customer fromJson(JsonObject jsonObj) { Customer obj = new Customer(); - // Parse JSON to extract all keys for custom field extraction java.util.Set knownFields = new java.util.HashSet<>(); knownFields.add("id"); @@ -1027,251 +1031,180 @@ public static Customer fromJson(String json) { knownFields.add("child_account_access"); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.firstName = JsonUtil.getString(json, "first_name"); + obj.firstName = JsonUtil.getString(jsonObj, "first_name"); - obj.lastName = JsonUtil.getString(json, "last_name"); + obj.lastName = JsonUtil.getString(jsonObj, "last_name"); - obj.email = JsonUtil.getString(json, "email"); + obj.email = JsonUtil.getString(jsonObj, "email"); - obj.phone = JsonUtil.getString(json, "phone"); + obj.phone = JsonUtil.getString(jsonObj, "phone"); - obj.company = JsonUtil.getString(json, "company"); + obj.company = JsonUtil.getString(jsonObj, "company"); - obj.vatNumber = JsonUtil.getString(json, "vat_number"); + obj.vatNumber = JsonUtil.getString(jsonObj, "vat_number"); - obj.autoCollection = AutoCollection.fromString(JsonUtil.getString(json, "auto_collection")); + obj.autoCollection = AutoCollection.fromString(JsonUtil.getString(jsonObj, "auto_collection")); obj.offlinePaymentMethod = - OfflinePaymentMethod.fromString(JsonUtil.getString(json, "offline_payment_method")); + OfflinePaymentMethod.fromString(JsonUtil.getString(jsonObj, "offline_payment_method")); - obj.netTermDays = JsonUtil.getInteger(json, "net_term_days"); + obj.netTermDays = JsonUtil.getInteger(jsonObj, "net_term_days"); - obj.vatNumberValidatedTime = JsonUtil.getTimestamp(json, "vat_number_validated_time"); + obj.vatNumberValidatedTime = JsonUtil.getTimestamp(jsonObj, "vat_number_validated_time"); - obj.vatNumberStatus = VatNumberStatus.fromString(JsonUtil.getString(json, "vat_number_status")); + obj.vatNumberStatus = + VatNumberStatus.fromString(JsonUtil.getString(jsonObj, "vat_number_status")); - obj.allowDirectDebit = JsonUtil.getBoolean(json, "allow_direct_debit"); + obj.allowDirectDebit = JsonUtil.getBoolean(jsonObj, "allow_direct_debit"); - obj.isLocationValid = JsonUtil.getBoolean(json, "is_location_valid"); + obj.isLocationValid = JsonUtil.getBoolean(jsonObj, "is_location_valid"); - obj.createdAt = JsonUtil.getTimestamp(json, "created_at"); + obj.createdAt = JsonUtil.getTimestamp(jsonObj, "created_at"); - obj.createdFromIp = JsonUtil.getString(json, "created_from_ip"); + obj.createdFromIp = JsonUtil.getString(jsonObj, "created_from_ip"); - String __exemptionDetailsJson = JsonUtil.getArray(json, "exemption_details"); obj.exemptionDetails = - __exemptionDetailsJson != null - ? JsonUtil.parseObjectArray(__exemptionDetailsJson).stream() - .map(JsonUtil::parseJsonObjectToMap) - .collect(java.util.stream.Collectors.toList()) - : null; + JsonUtil.mapArrayToObjects(JsonUtil.getJsonArray(jsonObj, "exemption_details")); - obj.taxability = Taxability.fromString(JsonUtil.getString(json, "taxability")); + obj.taxability = Taxability.fromString(JsonUtil.getString(jsonObj, "taxability")); - obj.entityCode = EntityCode.fromString(JsonUtil.getString(json, "entity_code")); + obj.entityCode = EntityCode.fromString(JsonUtil.getString(jsonObj, "entity_code")); - obj.exemptNumber = JsonUtil.getString(json, "exempt_number"); + obj.exemptNumber = JsonUtil.getString(jsonObj, "exempt_number"); - obj.resourceVersion = JsonUtil.getLong(json, "resource_version"); + obj.resourceVersion = JsonUtil.getLong(jsonObj, "resource_version"); - obj.updatedAt = JsonUtil.getTimestamp(json, "updated_at"); + obj.updatedAt = JsonUtil.getTimestamp(jsonObj, "updated_at"); - obj.locale = JsonUtil.getString(json, "locale"); + obj.locale = JsonUtil.getString(jsonObj, "locale"); - obj.billingDate = JsonUtil.getInteger(json, "billing_date"); + obj.billingDate = JsonUtil.getInteger(jsonObj, "billing_date"); - obj.billingMonth = JsonUtil.getInteger(json, "billing_month"); + obj.billingMonth = JsonUtil.getInteger(jsonObj, "billing_month"); - obj.billingDateMode = BillingDateMode.fromString(JsonUtil.getString(json, "billing_date_mode")); + obj.billingDateMode = + BillingDateMode.fromString(JsonUtil.getString(jsonObj, "billing_date_mode")); obj.billingDayOfWeek = - BillingDayOfWeek.fromString(JsonUtil.getString(json, "billing_day_of_week")); + BillingDayOfWeek.fromString(JsonUtil.getString(jsonObj, "billing_day_of_week")); obj.billingDayOfWeekMode = - BillingDayOfWeekMode.fromString(JsonUtil.getString(json, "billing_day_of_week_mode")); + BillingDayOfWeekMode.fromString(JsonUtil.getString(jsonObj, "billing_day_of_week_mode")); - obj.piiCleared = PiiCleared.fromString(JsonUtil.getString(json, "pii_cleared")); + obj.piiCleared = PiiCleared.fromString(JsonUtil.getString(jsonObj, "pii_cleared")); - obj.autoCloseInvoices = JsonUtil.getBoolean(json, "auto_close_invoices"); + obj.autoCloseInvoices = JsonUtil.getBoolean(jsonObj, "auto_close_invoices"); - obj.channel = Channel.fromString(JsonUtil.getString(json, "channel")); + obj.channel = Channel.fromString(JsonUtil.getString(jsonObj, "channel")); - obj.activeId = JsonUtil.getString(json, "active_id"); + obj.activeId = JsonUtil.getString(jsonObj, "active_id"); - obj.cardStatus = CardStatus.fromString(JsonUtil.getString(json, "card_status")); + obj.cardStatus = CardStatus.fromString(JsonUtil.getString(jsonObj, "card_status")); - obj.fraudFlag = FraudFlag.fromString(JsonUtil.getString(json, "fraud_flag")); + obj.fraudFlag = FraudFlag.fromString(JsonUtil.getString(jsonObj, "fraud_flag")); - obj.primaryPaymentSourceId = JsonUtil.getString(json, "primary_payment_source_id"); + obj.primaryPaymentSourceId = JsonUtil.getString(jsonObj, "primary_payment_source_id"); - obj.backupPaymentSourceId = JsonUtil.getString(json, "backup_payment_source_id"); + obj.backupPaymentSourceId = JsonUtil.getString(jsonObj, "backup_payment_source_id"); - obj.invoiceNotes = JsonUtil.getString(json, "invoice_notes"); + obj.invoiceNotes = JsonUtil.getString(jsonObj, "invoice_notes"); - obj.businessEntityId = JsonUtil.getString(json, "business_entity_id"); + obj.businessEntityId = JsonUtil.getString(jsonObj, "business_entity_id"); - obj.preferredCurrencyCode = JsonUtil.getString(json, "preferred_currency_code"); + obj.preferredCurrencyCode = JsonUtil.getString(jsonObj, "preferred_currency_code"); - obj.promotionalCredits = JsonUtil.getLong(json, "promotional_credits"); + obj.promotionalCredits = JsonUtil.getLong(jsonObj, "promotional_credits"); - obj.unbilledCharges = JsonUtil.getLong(json, "unbilled_charges"); + obj.unbilledCharges = JsonUtil.getLong(jsonObj, "unbilled_charges"); - obj.refundableCredits = JsonUtil.getLong(json, "refundable_credits"); + obj.refundableCredits = JsonUtil.getLong(jsonObj, "refundable_credits"); - obj.excessPayments = JsonUtil.getLong(json, "excess_payments"); + obj.excessPayments = JsonUtil.getLong(jsonObj, "excess_payments"); - obj.isEinvoiceEnabled = JsonUtil.getBoolean(json, "is_einvoice_enabled"); + obj.isEinvoiceEnabled = JsonUtil.getBoolean(jsonObj, "is_einvoice_enabled"); obj.einvoicingMethod = - EinvoicingMethod.fromString(JsonUtil.getString(json, "einvoicing_method")); + EinvoicingMethod.fromString(JsonUtil.getString(jsonObj, "einvoicing_method")); - String __metaDataJson = JsonUtil.getObject(json, "meta_data"); + JsonObject __metaDataObj = JsonUtil.getJsonObject(jsonObj, "meta_data"); obj.metaData = - __metaDataJson != null - ? JsonUtil.parseJsonObjectToMap(__metaDataJson) + __metaDataObj != null + ? JsonUtil.parseJsonObjectToMap(__metaDataObj) : new java.util.HashMap<>(); - obj.deleted = JsonUtil.getBoolean(json, "deleted"); + obj.deleted = JsonUtil.getBoolean(jsonObj, "deleted"); - obj.registeredForGst = JsonUtil.getBoolean(json, "registered_for_gst"); + obj.registeredForGst = JsonUtil.getBoolean(jsonObj, "registered_for_gst"); - obj.consolidatedInvoicing = JsonUtil.getBoolean(json, "consolidated_invoicing"); + obj.consolidatedInvoicing = JsonUtil.getBoolean(jsonObj, "consolidated_invoicing"); - obj.customerType = CustomerType.fromString(JsonUtil.getString(json, "customer_type")); + obj.customerType = CustomerType.fromString(JsonUtil.getString(jsonObj, "customer_type")); obj.businessCustomerWithoutVatNumber = - JsonUtil.getBoolean(json, "business_customer_without_vat_number"); + JsonUtil.getBoolean(jsonObj, "business_customer_without_vat_number"); - obj.clientProfileId = JsonUtil.getString(json, "client_profile_id"); + obj.clientProfileId = JsonUtil.getString(jsonObj, "client_profile_id"); - obj.useDefaultHierarchySettings = JsonUtil.getBoolean(json, "use_default_hierarchy_settings"); + obj.useDefaultHierarchySettings = + JsonUtil.getBoolean(jsonObj, "use_default_hierarchy_settings"); - obj.vatNumberPrefix = JsonUtil.getString(json, "vat_number_prefix"); + obj.vatNumberPrefix = JsonUtil.getString(jsonObj, "vat_number_prefix"); - obj.entityIdentifierScheme = JsonUtil.getString(json, "entity_identifier_scheme"); + obj.entityIdentifierScheme = JsonUtil.getString(jsonObj, "entity_identifier_scheme"); - obj.entityIdentifierStandard = JsonUtil.getString(json, "entity_identifier_standard"); + obj.entityIdentifierStandard = JsonUtil.getString(jsonObj, "entity_identifier_standard"); - String __billingAddressJson = JsonUtil.getObject(json, "billing_address"); - if (__billingAddressJson != null) { - obj.billingAddress = BillingAddress.fromJson(__billingAddressJson); + JsonObject __billingAddressObj = JsonUtil.getJsonObject(jsonObj, "billing_address"); + if (__billingAddressObj != null) { + obj.billingAddress = BillingAddress.fromJson(__billingAddressObj); } obj.referralUrls = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "referral_urls")).stream() - .map(ReferralUrls::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "referral_urls"), ReferralUrls::fromJson); obj.contacts = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "contacts")).stream() - .map(Contacts::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "contacts"), Contacts::fromJson); - String __paymentMethodJson = JsonUtil.getObject(json, "payment_method"); - if (__paymentMethodJson != null) { - obj.paymentMethod = PaymentMethod.fromJson(__paymentMethodJson); + JsonObject __paymentMethodObj = JsonUtil.getJsonObject(jsonObj, "payment_method"); + if (__paymentMethodObj != null) { + obj.paymentMethod = PaymentMethod.fromJson(__paymentMethodObj); } obj.balances = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "balances")).stream() - .map(Balances::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "balances"), Balances::fromJson); obj.entityIdentifiers = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "entity_identifiers")).stream() - .map(EntityIdentifiers::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "entity_identifiers"), EntityIdentifiers::fromJson); obj.taxProvidersFields = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "tax_providers_fields")).stream() - .map(TaxProvidersFields::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "tax_providers_fields"), TaxProvidersFields::fromJson); - String __relationshipJson = JsonUtil.getObject(json, "relationship"); - if (__relationshipJson != null) { - obj.relationship = Relationship.fromJson(__relationshipJson); + JsonObject __relationshipObj = JsonUtil.getJsonObject(jsonObj, "relationship"); + if (__relationshipObj != null) { + obj.relationship = Relationship.fromJson(__relationshipObj); } - String __parentAccountAccessJson = JsonUtil.getObject(json, "parent_account_access"); - if (__parentAccountAccessJson != null) { - obj.parentAccountAccess = ParentAccountAccess.fromJson(__parentAccountAccessJson); + JsonObject __parentAccountAccessObj = JsonUtil.getJsonObject(jsonObj, "parent_account_access"); + if (__parentAccountAccessObj != null) { + obj.parentAccountAccess = ParentAccountAccess.fromJson(__parentAccountAccessObj); } - String __childAccountAccessJson = JsonUtil.getObject(json, "child_account_access"); - if (__childAccountAccessJson != null) { - obj.childAccountAccess = ChildAccountAccess.fromJson(__childAccountAccessJson); + JsonObject __childAccountAccessObj = JsonUtil.getJsonObject(jsonObj, "child_account_access"); + if (__childAccountAccessObj != null) { + obj.childAccountAccess = ChildAccountAccess.fromJson(__childAccountAccessObj); } - // Extract custom fields (fields starting with cf_) - obj.customFields = extractCustomFields(json, knownFields); + obj.customFields = JsonUtil.extractCustomFields(jsonObj, knownFields); - // Extract consent fields (fields starting with cs_) - obj.consentFields = extractConsentFields(json, knownFields); + obj.consentFields = JsonUtil.extractConsentFields(jsonObj, knownFields); return obj; } - /** - * Helper method to extract custom fields from JSON. Custom fields are fields that start with - * "cf_" and are not in the known fields set. - * - * @param json JSON string to parse - * @param knownFields set of known field names - * @return map of custom fields - */ - private static java.util.Map extractCustomFields( - String json, java.util.Set knownFields) { - java.util.Map customFields = new java.util.HashMap<>(); - try { - // Parse the entire JSON as a map - java.util.Map allFields = JsonUtil.parseJsonObjectToMap(json); - if (allFields != null) { - for (java.util.Map.Entry entry : allFields.entrySet()) { - String key = entry.getKey(); - // Include fields that start with "cf_" and are not in knownFields - if (key != null && key.startsWith("cf_") && !knownFields.contains(key)) { - customFields.put( - key, entry.getValue() != null ? String.valueOf(entry.getValue()) : null); - } - } - } - } catch (Exception e) { - // If parsing fails, return empty map - } - return customFields; - } - - /** - * Helper method to extract consent fields from JSON. Consent fields are fields that start with - * "cs_" and are not in the known fields set. They typically contain boolean values or options. - * - * @param json JSON string to parse - * @param knownFields set of known field names - * @return map of consent fields - */ - private static java.util.Map extractConsentFields( - String json, java.util.Set knownFields) { - java.util.Map consentFields = new java.util.HashMap<>(); - try { - // Parse the entire JSON as a map - java.util.Map allFields = JsonUtil.parseJsonObjectToMap(json); - if (allFields != null) { - for (java.util.Map.Entry entry : allFields.entrySet()) { - String key = entry.getKey(); - // Include fields that start with "cs_" and are not in knownFields - if (key != null && key.startsWith("cs_") && !knownFields.contains(key)) { - consentFields.put(key, entry.getValue()); - } - } - } - } catch (Exception e) { - // If parsing fails, return empty map - } - return consentFields; - } - @Override public String toString() { return "Customer{" @@ -1671,36 +1604,40 @@ public static ValidationStatus fromString(String value) { } public static BillingAddress fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static BillingAddress fromJson(JsonObject jsonObj) { BillingAddress obj = new BillingAddress(); - obj.firstName = JsonUtil.getString(json, "first_name"); + obj.firstName = JsonUtil.getString(jsonObj, "first_name"); - obj.lastName = JsonUtil.getString(json, "last_name"); + obj.lastName = JsonUtil.getString(jsonObj, "last_name"); - obj.email = JsonUtil.getString(json, "email"); + obj.email = JsonUtil.getString(jsonObj, "email"); - obj.company = JsonUtil.getString(json, "company"); + obj.company = JsonUtil.getString(jsonObj, "company"); - obj.phone = JsonUtil.getString(json, "phone"); + obj.phone = JsonUtil.getString(jsonObj, "phone"); - obj.line1 = JsonUtil.getString(json, "line1"); + obj.line1 = JsonUtil.getString(jsonObj, "line1"); - obj.line2 = JsonUtil.getString(json, "line2"); + obj.line2 = JsonUtil.getString(jsonObj, "line2"); - obj.line3 = JsonUtil.getString(json, "line3"); + obj.line3 = JsonUtil.getString(jsonObj, "line3"); - obj.city = JsonUtil.getString(json, "city"); + obj.city = JsonUtil.getString(jsonObj, "city"); - obj.stateCode = JsonUtil.getString(json, "state_code"); + obj.stateCode = JsonUtil.getString(jsonObj, "state_code"); - obj.state = JsonUtil.getString(json, "state"); + obj.state = JsonUtil.getString(jsonObj, "state"); - obj.country = JsonUtil.getString(json, "country"); + obj.country = JsonUtil.getString(jsonObj, "country"); - obj.zip = JsonUtil.getString(json, "zip"); + obj.zip = JsonUtil.getString(jsonObj, "zip"); obj.validationStatus = - ValidationStatus.fromString(JsonUtil.getString(json, "validation_status")); + ValidationStatus.fromString(JsonUtil.getString(jsonObj, "validation_status")); return obj; } @@ -1856,23 +1793,28 @@ public static ReferralSystem fromString(String value) { } public static ReferralUrls fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static ReferralUrls fromJson(JsonObject jsonObj) { ReferralUrls obj = new ReferralUrls(); - obj.externalCustomerId = JsonUtil.getString(json, "external_customer_id"); + obj.externalCustomerId = JsonUtil.getString(jsonObj, "external_customer_id"); - obj.referralSharingUrl = JsonUtil.getString(json, "referral_sharing_url"); + obj.referralSharingUrl = JsonUtil.getString(jsonObj, "referral_sharing_url"); - obj.createdAt = JsonUtil.getTimestamp(json, "created_at"); + obj.createdAt = JsonUtil.getTimestamp(jsonObj, "created_at"); - obj.updatedAt = JsonUtil.getTimestamp(json, "updated_at"); + obj.updatedAt = JsonUtil.getTimestamp(jsonObj, "updated_at"); - obj.referralCampaignId = JsonUtil.getString(json, "referral_campaign_id"); + obj.referralCampaignId = JsonUtil.getString(jsonObj, "referral_campaign_id"); - obj.referralAccountId = JsonUtil.getString(json, "referral_account_id"); + obj.referralAccountId = JsonUtil.getString(jsonObj, "referral_account_id"); - obj.referralExternalCampaignId = JsonUtil.getString(json, "referral_external_campaign_id"); + obj.referralExternalCampaignId = JsonUtil.getString(jsonObj, "referral_external_campaign_id"); - obj.referralSystem = ReferralSystem.fromString(JsonUtil.getString(json, "referral_system")); + obj.referralSystem = + ReferralSystem.fromString(JsonUtil.getString(jsonObj, "referral_system")); return obj; } @@ -1979,25 +1921,29 @@ public Boolean getSendBillingEmail() { } public static Contacts fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Contacts fromJson(JsonObject jsonObj) { Contacts obj = new Contacts(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.firstName = JsonUtil.getString(json, "first_name"); + obj.firstName = JsonUtil.getString(jsonObj, "first_name"); - obj.lastName = JsonUtil.getString(json, "last_name"); + obj.lastName = JsonUtil.getString(jsonObj, "last_name"); - obj.email = JsonUtil.getString(json, "email"); + obj.email = JsonUtil.getString(jsonObj, "email"); - obj.phone = JsonUtil.getString(json, "phone"); + obj.phone = JsonUtil.getString(jsonObj, "phone"); - obj.label = JsonUtil.getString(json, "label"); + obj.label = JsonUtil.getString(jsonObj, "label"); - obj.enabled = JsonUtil.getBoolean(json, "enabled"); + obj.enabled = JsonUtil.getBoolean(jsonObj, "enabled"); - obj.sendAccountEmail = JsonUtil.getBoolean(json, "send_account_email"); + obj.sendAccountEmail = JsonUtil.getBoolean(jsonObj, "send_account_email"); - obj.sendBillingEmail = JsonUtil.getBoolean(json, "send_billing_email"); + obj.sendBillingEmail = JsonUtil.getBoolean(jsonObj, "send_billing_email"); return obj; } @@ -2356,17 +2302,21 @@ public static Status fromString(String value) { } public static PaymentMethod fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static PaymentMethod fromJson(JsonObject jsonObj) { PaymentMethod obj = new PaymentMethod(); - obj.type = Type.fromString(JsonUtil.getString(json, "type")); + obj.type = Type.fromString(JsonUtil.getString(jsonObj, "type")); - obj.gateway = Gateway.fromString(JsonUtil.getString(json, "gateway")); + obj.gateway = Gateway.fromString(JsonUtil.getString(jsonObj, "gateway")); - obj.gatewayAccountId = JsonUtil.getString(json, "gateway_account_id"); + obj.gatewayAccountId = JsonUtil.getString(jsonObj, "gateway_account_id"); - obj.status = Status.fromString(JsonUtil.getString(json, "status")); + obj.status = Status.fromString(JsonUtil.getString(jsonObj, "status")); - obj.referenceId = JsonUtil.getString(json, "reference_id"); + obj.referenceId = JsonUtil.getString(jsonObj, "reference_id"); return obj; } @@ -2447,21 +2397,25 @@ public String getBusinessEntityId() { } public static Balances fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Balances fromJson(JsonObject jsonObj) { Balances obj = new Balances(); - obj.promotionalCredits = JsonUtil.getLong(json, "promotional_credits"); + obj.promotionalCredits = JsonUtil.getLong(jsonObj, "promotional_credits"); - obj.excessPayments = JsonUtil.getLong(json, "excess_payments"); + obj.excessPayments = JsonUtil.getLong(jsonObj, "excess_payments"); - obj.refundableCredits = JsonUtil.getLong(json, "refundable_credits"); + obj.refundableCredits = JsonUtil.getLong(jsonObj, "refundable_credits"); - obj.unbilledCharges = JsonUtil.getLong(json, "unbilled_charges"); + obj.unbilledCharges = JsonUtil.getLong(jsonObj, "unbilled_charges"); - obj.currencyCode = JsonUtil.getString(json, "currency_code"); + obj.currencyCode = JsonUtil.getString(jsonObj, "currency_code"); - obj.balanceCurrencyCode = JsonUtil.getString(json, "balance_currency_code"); + obj.balanceCurrencyCode = JsonUtil.getString(jsonObj, "balance_currency_code"); - obj.businessEntityId = JsonUtil.getString(json, "business_entity_id"); + obj.businessEntityId = JsonUtil.getString(jsonObj, "business_entity_id"); return obj; } @@ -2539,15 +2493,19 @@ public String getStandard() { } public static EntityIdentifiers fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static EntityIdentifiers fromJson(JsonObject jsonObj) { EntityIdentifiers obj = new EntityIdentifiers(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.value = JsonUtil.getString(json, "value"); + obj.value = JsonUtil.getString(jsonObj, "value"); - obj.scheme = JsonUtil.getString(json, "scheme"); + obj.scheme = JsonUtil.getString(jsonObj, "scheme"); - obj.standard = JsonUtil.getString(json, "standard"); + obj.standard = JsonUtil.getString(jsonObj, "standard"); return obj; } @@ -2604,13 +2562,17 @@ public String getFieldValue() { } public static TaxProvidersFields fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static TaxProvidersFields fromJson(JsonObject jsonObj) { TaxProvidersFields obj = new TaxProvidersFields(); - obj.providerName = JsonUtil.getString(json, "provider_name"); + obj.providerName = JsonUtil.getString(jsonObj, "provider_name"); - obj.fieldId = JsonUtil.getString(json, "field_id"); + obj.fieldId = JsonUtil.getString(jsonObj, "field_id"); - obj.fieldValue = JsonUtil.getString(json, "field_value"); + obj.fieldValue = JsonUtil.getString(jsonObj, "field_value"); return obj; } @@ -2664,13 +2626,17 @@ public String getInvoiceOwnerId() { } public static Relationship fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Relationship fromJson(JsonObject jsonObj) { Relationship obj = new Relationship(); - obj.parentId = JsonUtil.getString(json, "parent_id"); + obj.parentId = JsonUtil.getString(jsonObj, "parent_id"); - obj.paymentOwnerId = JsonUtil.getString(json, "payment_owner_id"); + obj.paymentOwnerId = JsonUtil.getString(jsonObj, "payment_owner_id"); - obj.invoiceOwnerId = JsonUtil.getString(json, "invoice_owner_id"); + obj.invoiceOwnerId = JsonUtil.getString(jsonObj, "invoice_owner_id"); return obj; } @@ -2800,21 +2766,25 @@ public static PortalDownloadChildInvoices fromString(String value) { } public static ParentAccountAccess fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static ParentAccountAccess fromJson(JsonObject jsonObj) { ParentAccountAccess obj = new ParentAccountAccess(); obj.portalEditChildSubscriptions = PortalEditChildSubscriptions.fromString( - JsonUtil.getString(json, "portal_edit_child_subscriptions")); + JsonUtil.getString(jsonObj, "portal_edit_child_subscriptions")); obj.portalDownloadChildInvoices = PortalDownloadChildInvoices.fromString( - JsonUtil.getString(json, "portal_download_child_invoices")); + JsonUtil.getString(jsonObj, "portal_download_child_invoices")); - obj.sendSubscriptionEmails = JsonUtil.getBoolean(json, "send_subscription_emails"); + obj.sendSubscriptionEmails = JsonUtil.getBoolean(jsonObj, "send_subscription_emails"); - obj.sendInvoiceEmails = JsonUtil.getBoolean(json, "send_invoice_emails"); + obj.sendInvoiceEmails = JsonUtil.getBoolean(jsonObj, "send_invoice_emails"); - obj.sendPaymentEmails = JsonUtil.getBoolean(json, "send_payment_emails"); + obj.sendPaymentEmails = JsonUtil.getBoolean(jsonObj, "send_payment_emails"); return obj; } @@ -2954,19 +2924,25 @@ public static PortalDownloadInvoices fromString(String value) { } public static ChildAccountAccess fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static ChildAccountAccess fromJson(JsonObject jsonObj) { ChildAccountAccess obj = new ChildAccountAccess(); obj.portalEditSubscriptions = - PortalEditSubscriptions.fromString(JsonUtil.getString(json, "portal_edit_subscriptions")); + PortalEditSubscriptions.fromString( + JsonUtil.getString(jsonObj, "portal_edit_subscriptions")); obj.portalDownloadInvoices = - PortalDownloadInvoices.fromString(JsonUtil.getString(json, "portal_download_invoices")); + PortalDownloadInvoices.fromString( + JsonUtil.getString(jsonObj, "portal_download_invoices")); - obj.sendSubscriptionEmails = JsonUtil.getBoolean(json, "send_subscription_emails"); + obj.sendSubscriptionEmails = JsonUtil.getBoolean(jsonObj, "send_subscription_emails"); - obj.sendInvoiceEmails = JsonUtil.getBoolean(json, "send_invoice_emails"); + obj.sendInvoiceEmails = JsonUtil.getBoolean(jsonObj, "send_invoice_emails"); - obj.sendPaymentEmails = JsonUtil.getBoolean(json, "send_payment_emails"); + obj.sendPaymentEmails = JsonUtil.getBoolean(jsonObj, "send_payment_emails"); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/customer/responses/ContactsForCustomerResponse.java b/src/main/java/com/chargebee/v4/models/customer/responses/ContactsForCustomerResponse.java index f4530157..921f039e 100644 --- a/src/main/java/com/chargebee/v4/models/customer/responses/ContactsForCustomerResponse.java +++ b/src/main/java/com/chargebee/v4/models/customer/responses/ContactsForCustomerResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.exceptions.ChargebeeException; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; import com.chargebee.v4.services.CustomerService; import com.chargebee.v4.models.customer.params.ContactsForCustomerParams; @@ -48,13 +49,13 @@ private ContactsForCustomerResponse( */ public static ContactsForCustomerResponse fromJson(String json) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(CustomerContactsForCustomerItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "list"), CustomerContactsForCustomerItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new ContactsForCustomerResponse(list, nextOffset, null, null, null, null); } catch (Exception e) { @@ -73,13 +74,13 @@ public static ContactsForCustomerResponse fromJson( String customerId, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(CustomerContactsForCustomerItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "list"), CustomerContactsForCustomerItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new ContactsForCustomerResponse( list, nextOffset, customerId, service, originalParams, httpResponse); @@ -180,11 +181,15 @@ public Contact getContact() { } public static CustomerContactsForCustomerItem fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static CustomerContactsForCustomerItem fromJson(JsonObject jsonObj) { CustomerContactsForCustomerItem item = new CustomerContactsForCustomerItem(); - String __contactJson = JsonUtil.getObject(json, "contact"); - if (__contactJson != null) { - item.contact = Contact.fromJson(__contactJson); + JsonObject __contactObj = JsonUtil.getJsonObject(jsonObj, "contact"); + if (__contactObj != null) { + item.contact = Contact.fromJson(__contactObj); } return item; diff --git a/src/main/java/com/chargebee/v4/models/customer/responses/CustomerAddContactResponse.java b/src/main/java/com/chargebee/v4/models/customer/responses/CustomerAddContactResponse.java index dfd553ec..550b39e5 100644 --- a/src/main/java/com/chargebee/v4/models/customer/responses/CustomerAddContactResponse.java +++ b/src/main/java/com/chargebee/v4/models/customer/responses/CustomerAddContactResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -33,16 +34,17 @@ public static CustomerAddContactResponse fromJson(String json) { /** Parse JSON response into CustomerAddContactResponse object with HTTP response. */ public static CustomerAddContactResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - builder.customer(Customer.fromJson(__customerJson)); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + builder.customer(Customer.fromJson(__customerObj)); } - String __cardJson = JsonUtil.getObject(json, "card"); - if (__cardJson != null) { - builder.card(Card.fromJson(__cardJson)); + JsonObject __cardObj = JsonUtil.getJsonObject(jsonObj, "card"); + if (__cardObj != null) { + builder.card(Card.fromJson(__cardObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/customer/responses/CustomerAddPromotionalCreditsResponse.java b/src/main/java/com/chargebee/v4/models/customer/responses/CustomerAddPromotionalCreditsResponse.java index 36589bed..d1d62be8 100644 --- a/src/main/java/com/chargebee/v4/models/customer/responses/CustomerAddPromotionalCreditsResponse.java +++ b/src/main/java/com/chargebee/v4/models/customer/responses/CustomerAddPromotionalCreditsResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static CustomerAddPromotionalCreditsResponse fromJson(String json) { /** Parse JSON response into CustomerAddPromotionalCreditsResponse object with HTTP response. */ public static CustomerAddPromotionalCreditsResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - builder.customer(Customer.fromJson(__customerJson)); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + builder.customer(Customer.fromJson(__customerObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/customer/responses/CustomerAssignPaymentRoleResponse.java b/src/main/java/com/chargebee/v4/models/customer/responses/CustomerAssignPaymentRoleResponse.java index 6f1560d1..04df486d 100644 --- a/src/main/java/com/chargebee/v4/models/customer/responses/CustomerAssignPaymentRoleResponse.java +++ b/src/main/java/com/chargebee/v4/models/customer/responses/CustomerAssignPaymentRoleResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -33,16 +34,17 @@ public static CustomerAssignPaymentRoleResponse fromJson(String json) { /** Parse JSON response into CustomerAssignPaymentRoleResponse object with HTTP response. */ public static CustomerAssignPaymentRoleResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - builder.customer(Customer.fromJson(__customerJson)); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + builder.customer(Customer.fromJson(__customerObj)); } - String __paymentSourceJson = JsonUtil.getObject(json, "payment_source"); - if (__paymentSourceJson != null) { - builder.paymentSource(PaymentSource.fromJson(__paymentSourceJson)); + JsonObject __paymentSourceObj = JsonUtil.getJsonObject(jsonObj, "payment_source"); + if (__paymentSourceObj != null) { + builder.paymentSource(PaymentSource.fromJson(__paymentSourceObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/customer/responses/CustomerChangeBillingDateResponse.java b/src/main/java/com/chargebee/v4/models/customer/responses/CustomerChangeBillingDateResponse.java index c82671ce..c450dc03 100644 --- a/src/main/java/com/chargebee/v4/models/customer/responses/CustomerChangeBillingDateResponse.java +++ b/src/main/java/com/chargebee/v4/models/customer/responses/CustomerChangeBillingDateResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static CustomerChangeBillingDateResponse fromJson(String json) { /** Parse JSON response into CustomerChangeBillingDateResponse object with HTTP response. */ public static CustomerChangeBillingDateResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - builder.customer(Customer.fromJson(__customerJson)); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + builder.customer(Customer.fromJson(__customerObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/customer/responses/CustomerClearPersonalDataResponse.java b/src/main/java/com/chargebee/v4/models/customer/responses/CustomerClearPersonalDataResponse.java index 05bb1ac4..f6f33658 100644 --- a/src/main/java/com/chargebee/v4/models/customer/responses/CustomerClearPersonalDataResponse.java +++ b/src/main/java/com/chargebee/v4/models/customer/responses/CustomerClearPersonalDataResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static CustomerClearPersonalDataResponse fromJson(String json) { /** Parse JSON response into CustomerClearPersonalDataResponse object with HTTP response. */ public static CustomerClearPersonalDataResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - builder.customer(Customer.fromJson(__customerJson)); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + builder.customer(Customer.fromJson(__customerObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/customer/responses/CustomerCollectPaymentResponse.java b/src/main/java/com/chargebee/v4/models/customer/responses/CustomerCollectPaymentResponse.java index e12820a7..ce91da4e 100644 --- a/src/main/java/com/chargebee/v4/models/customer/responses/CustomerCollectPaymentResponse.java +++ b/src/main/java/com/chargebee/v4/models/customer/responses/CustomerCollectPaymentResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -33,16 +34,17 @@ public static CustomerCollectPaymentResponse fromJson(String json) { /** Parse JSON response into CustomerCollectPaymentResponse object with HTTP response. */ public static CustomerCollectPaymentResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - builder.customer(Customer.fromJson(__customerJson)); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + builder.customer(Customer.fromJson(__customerObj)); } - String __transactionJson = JsonUtil.getObject(json, "transaction"); - if (__transactionJson != null) { - builder.transaction(Transaction.fromJson(__transactionJson)); + JsonObject __transactionObj = JsonUtil.getJsonObject(jsonObj, "transaction"); + if (__transactionObj != null) { + builder.transaction(Transaction.fromJson(__transactionObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/customer/responses/CustomerCreateResponse.java b/src/main/java/com/chargebee/v4/models/customer/responses/CustomerCreateResponse.java index b3b1665d..c9498d87 100644 --- a/src/main/java/com/chargebee/v4/models/customer/responses/CustomerCreateResponse.java +++ b/src/main/java/com/chargebee/v4/models/customer/responses/CustomerCreateResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -32,16 +33,17 @@ public static CustomerCreateResponse fromJson(String json) { /** Parse JSON response into CustomerCreateResponse object with HTTP response. */ public static CustomerCreateResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - builder.customer(Customer.fromJson(__customerJson)); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + builder.customer(Customer.fromJson(__customerObj)); } - String __cardJson = JsonUtil.getObject(json, "card"); - if (__cardJson != null) { - builder.card(Card.fromJson(__cardJson)); + JsonObject __cardObj = JsonUtil.getJsonObject(jsonObj, "card"); + if (__cardObj != null) { + builder.card(Card.fromJson(__cardObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/customer/responses/CustomerDeductPromotionalCreditsResponse.java b/src/main/java/com/chargebee/v4/models/customer/responses/CustomerDeductPromotionalCreditsResponse.java index 48ee35e5..68877a35 100644 --- a/src/main/java/com/chargebee/v4/models/customer/responses/CustomerDeductPromotionalCreditsResponse.java +++ b/src/main/java/com/chargebee/v4/models/customer/responses/CustomerDeductPromotionalCreditsResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -30,11 +31,12 @@ public static CustomerDeductPromotionalCreditsResponse fromJson(String json) { public static CustomerDeductPromotionalCreditsResponse fromJson( String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - builder.customer(Customer.fromJson(__customerJson)); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + builder.customer(Customer.fromJson(__customerObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/customer/responses/CustomerDeleteContactResponse.java b/src/main/java/com/chargebee/v4/models/customer/responses/CustomerDeleteContactResponse.java index 8e13e837..7e313d91 100644 --- a/src/main/java/com/chargebee/v4/models/customer/responses/CustomerDeleteContactResponse.java +++ b/src/main/java/com/chargebee/v4/models/customer/responses/CustomerDeleteContactResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -33,16 +34,17 @@ public static CustomerDeleteContactResponse fromJson(String json) { /** Parse JSON response into CustomerDeleteContactResponse object with HTTP response. */ public static CustomerDeleteContactResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - builder.customer(Customer.fromJson(__customerJson)); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + builder.customer(Customer.fromJson(__customerObj)); } - String __cardJson = JsonUtil.getObject(json, "card"); - if (__cardJson != null) { - builder.card(Card.fromJson(__cardJson)); + JsonObject __cardObj = JsonUtil.getJsonObject(jsonObj, "card"); + if (__cardObj != null) { + builder.card(Card.fromJson(__cardObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/customer/responses/CustomerDeleteRelationshipResponse.java b/src/main/java/com/chargebee/v4/models/customer/responses/CustomerDeleteRelationshipResponse.java index 272d39ae..a863895c 100644 --- a/src/main/java/com/chargebee/v4/models/customer/responses/CustomerDeleteRelationshipResponse.java +++ b/src/main/java/com/chargebee/v4/models/customer/responses/CustomerDeleteRelationshipResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static CustomerDeleteRelationshipResponse fromJson(String json) { /** Parse JSON response into CustomerDeleteRelationshipResponse object with HTTP response. */ public static CustomerDeleteRelationshipResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - builder.customer(Customer.fromJson(__customerJson)); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + builder.customer(Customer.fromJson(__customerObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/customer/responses/CustomerDeleteResponse.java b/src/main/java/com/chargebee/v4/models/customer/responses/CustomerDeleteResponse.java index 4ac35d8d..d560b3d6 100644 --- a/src/main/java/com/chargebee/v4/models/customer/responses/CustomerDeleteResponse.java +++ b/src/main/java/com/chargebee/v4/models/customer/responses/CustomerDeleteResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -32,16 +33,17 @@ public static CustomerDeleteResponse fromJson(String json) { /** Parse JSON response into CustomerDeleteResponse object with HTTP response. */ public static CustomerDeleteResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - builder.customer(Customer.fromJson(__customerJson)); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + builder.customer(Customer.fromJson(__customerObj)); } - String __cardJson = JsonUtil.getObject(json, "card"); - if (__cardJson != null) { - builder.card(Card.fromJson(__cardJson)); + JsonObject __cardObj = JsonUtil.getJsonObject(jsonObj, "card"); + if (__cardObj != null) { + builder.card(Card.fromJson(__cardObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/customer/responses/CustomerHierarchyResponse.java b/src/main/java/com/chargebee/v4/models/customer/responses/CustomerHierarchyResponse.java index 6fcdb4b2..4a9b4a06 100644 --- a/src/main/java/com/chargebee/v4/models/customer/responses/CustomerHierarchyResponse.java +++ b/src/main/java/com/chargebee/v4/models/customer/responses/CustomerHierarchyResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; import java.util.List; @@ -28,15 +29,11 @@ public static CustomerHierarchyResponse fromJson(String json) { /** Parse JSON response into CustomerHierarchyResponse object with HTTP response. */ public static CustomerHierarchyResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __hierarchiesJson = JsonUtil.getArray(json, "hierarchies"); - if (__hierarchiesJson != null) { - builder.hierarchies( - JsonUtil.parseObjectArray(__hierarchiesJson).stream() - .map(Hierarchy::fromJson) - .collect(java.util.stream.Collectors.toList())); - } + builder.hierarchies( + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "hierarchies"), Hierarchy::fromJson)); builder.httpResponse(httpResponse); return builder.build(); diff --git a/src/main/java/com/chargebee/v4/models/customer/responses/CustomerListHierarchyDetailResponse.java b/src/main/java/com/chargebee/v4/models/customer/responses/CustomerListHierarchyDetailResponse.java index aa14dccd..d8bb0425 100644 --- a/src/main/java/com/chargebee/v4/models/customer/responses/CustomerListHierarchyDetailResponse.java +++ b/src/main/java/com/chargebee/v4/models/customer/responses/CustomerListHierarchyDetailResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.exceptions.ChargebeeException; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; import com.chargebee.v4.services.CustomerService; import com.chargebee.v4.models.customer.params.CustomerListHierarchyDetailParams; @@ -51,13 +52,13 @@ private CustomerListHierarchyDetailResponse( */ public static CustomerListHierarchyDetailResponse fromJson(String json) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(CustomerListHierarchyDetailItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "list"), CustomerListHierarchyDetailItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new CustomerListHierarchyDetailResponse(list, nextOffset, null, null, null, null); } catch (Exception e) { @@ -77,13 +78,13 @@ public static CustomerListHierarchyDetailResponse fromJson( String customerId, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(CustomerListHierarchyDetailItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "list"), CustomerListHierarchyDetailItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new CustomerListHierarchyDetailResponse( list, nextOffset, customerId, service, originalParams, httpResponse); @@ -192,11 +193,15 @@ public Hierarchy getHierarchy() { } public static CustomerListHierarchyDetailItem fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static CustomerListHierarchyDetailItem fromJson(JsonObject jsonObj) { CustomerListHierarchyDetailItem item = new CustomerListHierarchyDetailItem(); - String __hierarchyJson = JsonUtil.getObject(json, "hierarchy"); - if (__hierarchyJson != null) { - item.hierarchy = Hierarchy.fromJson(__hierarchyJson); + JsonObject __hierarchyObj = JsonUtil.getJsonObject(jsonObj, "hierarchy"); + if (__hierarchyObj != null) { + item.hierarchy = Hierarchy.fromJson(__hierarchyObj); } return item; diff --git a/src/main/java/com/chargebee/v4/models/customer/responses/CustomerListResponse.java b/src/main/java/com/chargebee/v4/models/customer/responses/CustomerListResponse.java index b2b64c10..53b94675 100644 --- a/src/main/java/com/chargebee/v4/models/customer/responses/CustomerListResponse.java +++ b/src/main/java/com/chargebee/v4/models/customer/responses/CustomerListResponse.java @@ -8,6 +8,7 @@ import com.chargebee.v4.exceptions.ChargebeeException; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; import com.chargebee.v4.services.CustomerService; import com.chargebee.v4.models.customer.params.CustomerListParams; @@ -45,13 +46,12 @@ private CustomerListResponse( */ public static CustomerListResponse fromJson(String json) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(CustomerListItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "list"), CustomerListItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new CustomerListResponse(list, nextOffset, null, null, null); } catch (Exception e) { @@ -69,13 +69,12 @@ public static CustomerListResponse fromJson( CustomerListParams originalParams, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(CustomerListItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "list"), CustomerListItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new CustomerListResponse(list, nextOffset, service, originalParams, httpResponse); } catch (Exception e) { @@ -181,16 +180,20 @@ public Card getCard() { } public static CustomerListItem fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static CustomerListItem fromJson(JsonObject jsonObj) { CustomerListItem item = new CustomerListItem(); - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - item.customer = Customer.fromJson(__customerJson); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + item.customer = Customer.fromJson(__customerObj); } - String __cardJson = JsonUtil.getObject(json, "card"); - if (__cardJson != null) { - item.card = Card.fromJson(__cardJson); + JsonObject __cardObj = JsonUtil.getJsonObject(jsonObj, "card"); + if (__cardObj != null) { + item.card = Card.fromJson(__cardObj); } return item; diff --git a/src/main/java/com/chargebee/v4/models/customer/responses/CustomerMergeResponse.java b/src/main/java/com/chargebee/v4/models/customer/responses/CustomerMergeResponse.java index 1674e3a3..9bad97d1 100644 --- a/src/main/java/com/chargebee/v4/models/customer/responses/CustomerMergeResponse.java +++ b/src/main/java/com/chargebee/v4/models/customer/responses/CustomerMergeResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -26,11 +27,12 @@ public static CustomerMergeResponse fromJson(String json) { /** Parse JSON response into CustomerMergeResponse object with HTTP response. */ public static CustomerMergeResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - builder.customer(Customer.fromJson(__customerJson)); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + builder.customer(Customer.fromJson(__customerObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/customer/responses/CustomerMoveResponse.java b/src/main/java/com/chargebee/v4/models/customer/responses/CustomerMoveResponse.java index 8b80f425..d2a61f56 100644 --- a/src/main/java/com/chargebee/v4/models/customer/responses/CustomerMoveResponse.java +++ b/src/main/java/com/chargebee/v4/models/customer/responses/CustomerMoveResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -26,11 +27,12 @@ public static CustomerMoveResponse fromJson(String json) { /** Parse JSON response into CustomerMoveResponse object with HTTP response. */ public static CustomerMoveResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __resourceMigrationJson = JsonUtil.getObject(json, "resource_migration"); - if (__resourceMigrationJson != null) { - builder.resourceMigration(ResourceMigration.fromJson(__resourceMigrationJson)); + JsonObject __resourceMigrationObj = JsonUtil.getJsonObject(jsonObj, "resource_migration"); + if (__resourceMigrationObj != null) { + builder.resourceMigration(ResourceMigration.fromJson(__resourceMigrationObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/customer/responses/CustomerRecordExcessPaymentResponse.java b/src/main/java/com/chargebee/v4/models/customer/responses/CustomerRecordExcessPaymentResponse.java index 8f9d6d4c..96207701 100644 --- a/src/main/java/com/chargebee/v4/models/customer/responses/CustomerRecordExcessPaymentResponse.java +++ b/src/main/java/com/chargebee/v4/models/customer/responses/CustomerRecordExcessPaymentResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -33,16 +34,17 @@ public static CustomerRecordExcessPaymentResponse fromJson(String json) { /** Parse JSON response into CustomerRecordExcessPaymentResponse object with HTTP response. */ public static CustomerRecordExcessPaymentResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - builder.customer(Customer.fromJson(__customerJson)); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + builder.customer(Customer.fromJson(__customerObj)); } - String __transactionJson = JsonUtil.getObject(json, "transaction"); - if (__transactionJson != null) { - builder.transaction(Transaction.fromJson(__transactionJson)); + JsonObject __transactionObj = JsonUtil.getJsonObject(jsonObj, "transaction"); + if (__transactionObj != null) { + builder.transaction(Transaction.fromJson(__transactionObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/customer/responses/CustomerRelationshipsResponse.java b/src/main/java/com/chargebee/v4/models/customer/responses/CustomerRelationshipsResponse.java index 5bc132ea..56514c2f 100644 --- a/src/main/java/com/chargebee/v4/models/customer/responses/CustomerRelationshipsResponse.java +++ b/src/main/java/com/chargebee/v4/models/customer/responses/CustomerRelationshipsResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static CustomerRelationshipsResponse fromJson(String json) { /** Parse JSON response into CustomerRelationshipsResponse object with HTTP response. */ public static CustomerRelationshipsResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - builder.customer(Customer.fromJson(__customerJson)); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + builder.customer(Customer.fromJson(__customerObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/customer/responses/CustomerRetrieveResponse.java b/src/main/java/com/chargebee/v4/models/customer/responses/CustomerRetrieveResponse.java index 5a589edf..4bebdf11 100644 --- a/src/main/java/com/chargebee/v4/models/customer/responses/CustomerRetrieveResponse.java +++ b/src/main/java/com/chargebee/v4/models/customer/responses/CustomerRetrieveResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -33,16 +34,17 @@ public static CustomerRetrieveResponse fromJson(String json) { /** Parse JSON response into CustomerRetrieveResponse object with HTTP response. */ public static CustomerRetrieveResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - builder.customer(Customer.fromJson(__customerJson)); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + builder.customer(Customer.fromJson(__customerObj)); } - String __cardJson = JsonUtil.getObject(json, "card"); - if (__cardJson != null) { - builder.card(Card.fromJson(__cardJson)); + JsonObject __cardObj = JsonUtil.getJsonObject(jsonObj, "card"); + if (__cardObj != null) { + builder.card(Card.fromJson(__cardObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/customer/responses/CustomerSetPromotionalCreditsResponse.java b/src/main/java/com/chargebee/v4/models/customer/responses/CustomerSetPromotionalCreditsResponse.java index 05557dc3..fe2a750b 100644 --- a/src/main/java/com/chargebee/v4/models/customer/responses/CustomerSetPromotionalCreditsResponse.java +++ b/src/main/java/com/chargebee/v4/models/customer/responses/CustomerSetPromotionalCreditsResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static CustomerSetPromotionalCreditsResponse fromJson(String json) { /** Parse JSON response into CustomerSetPromotionalCreditsResponse object with HTTP response. */ public static CustomerSetPromotionalCreditsResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - builder.customer(Customer.fromJson(__customerJson)); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + builder.customer(Customer.fromJson(__customerObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/customer/responses/CustomerUpdateBillingInfoResponse.java b/src/main/java/com/chargebee/v4/models/customer/responses/CustomerUpdateBillingInfoResponse.java index 8175f52a..542f1e7a 100644 --- a/src/main/java/com/chargebee/v4/models/customer/responses/CustomerUpdateBillingInfoResponse.java +++ b/src/main/java/com/chargebee/v4/models/customer/responses/CustomerUpdateBillingInfoResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -33,16 +34,17 @@ public static CustomerUpdateBillingInfoResponse fromJson(String json) { /** Parse JSON response into CustomerUpdateBillingInfoResponse object with HTTP response. */ public static CustomerUpdateBillingInfoResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - builder.customer(Customer.fromJson(__customerJson)); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + builder.customer(Customer.fromJson(__customerObj)); } - String __cardJson = JsonUtil.getObject(json, "card"); - if (__cardJson != null) { - builder.card(Card.fromJson(__cardJson)); + JsonObject __cardObj = JsonUtil.getJsonObject(jsonObj, "card"); + if (__cardObj != null) { + builder.card(Card.fromJson(__cardObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/customer/responses/CustomerUpdateContactResponse.java b/src/main/java/com/chargebee/v4/models/customer/responses/CustomerUpdateContactResponse.java index cacbc57e..8cc8b29f 100644 --- a/src/main/java/com/chargebee/v4/models/customer/responses/CustomerUpdateContactResponse.java +++ b/src/main/java/com/chargebee/v4/models/customer/responses/CustomerUpdateContactResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -33,16 +34,17 @@ public static CustomerUpdateContactResponse fromJson(String json) { /** Parse JSON response into CustomerUpdateContactResponse object with HTTP response. */ public static CustomerUpdateContactResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - builder.customer(Customer.fromJson(__customerJson)); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + builder.customer(Customer.fromJson(__customerObj)); } - String __cardJson = JsonUtil.getObject(json, "card"); - if (__cardJson != null) { - builder.card(Card.fromJson(__cardJson)); + JsonObject __cardObj = JsonUtil.getJsonObject(jsonObj, "card"); + if (__cardObj != null) { + builder.card(Card.fromJson(__cardObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/customer/responses/CustomerUpdateHierarchySettingsResponse.java b/src/main/java/com/chargebee/v4/models/customer/responses/CustomerUpdateHierarchySettingsResponse.java index 34f8e9ab..b41252bd 100644 --- a/src/main/java/com/chargebee/v4/models/customer/responses/CustomerUpdateHierarchySettingsResponse.java +++ b/src/main/java/com/chargebee/v4/models/customer/responses/CustomerUpdateHierarchySettingsResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -28,11 +29,12 @@ public static CustomerUpdateHierarchySettingsResponse fromJson(String json) { public static CustomerUpdateHierarchySettingsResponse fromJson( String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - builder.customer(Customer.fromJson(__customerJson)); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + builder.customer(Customer.fromJson(__customerObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/customer/responses/CustomerUpdatePaymentMethodResponse.java b/src/main/java/com/chargebee/v4/models/customer/responses/CustomerUpdatePaymentMethodResponse.java index 097794f1..0c7e4025 100644 --- a/src/main/java/com/chargebee/v4/models/customer/responses/CustomerUpdatePaymentMethodResponse.java +++ b/src/main/java/com/chargebee/v4/models/customer/responses/CustomerUpdatePaymentMethodResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -33,16 +34,17 @@ public static CustomerUpdatePaymentMethodResponse fromJson(String json) { /** Parse JSON response into CustomerUpdatePaymentMethodResponse object with HTTP response. */ public static CustomerUpdatePaymentMethodResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - builder.customer(Customer.fromJson(__customerJson)); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + builder.customer(Customer.fromJson(__customerObj)); } - String __cardJson = JsonUtil.getObject(json, "card"); - if (__cardJson != null) { - builder.card(Card.fromJson(__cardJson)); + JsonObject __cardObj = JsonUtil.getJsonObject(jsonObj, "card"); + if (__cardObj != null) { + builder.card(Card.fromJson(__cardObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/customer/responses/CustomerUpdateResponse.java b/src/main/java/com/chargebee/v4/models/customer/responses/CustomerUpdateResponse.java index 91fc809f..88536a6c 100644 --- a/src/main/java/com/chargebee/v4/models/customer/responses/CustomerUpdateResponse.java +++ b/src/main/java/com/chargebee/v4/models/customer/responses/CustomerUpdateResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -32,16 +33,17 @@ public static CustomerUpdateResponse fromJson(String json) { /** Parse JSON response into CustomerUpdateResponse object with HTTP response. */ public static CustomerUpdateResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - builder.customer(Customer.fromJson(__customerJson)); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + builder.customer(Customer.fromJson(__customerObj)); } - String __cardJson = JsonUtil.getObject(json, "card"); - if (__cardJson != null) { - builder.card(Card.fromJson(__cardJson)); + JsonObject __cardObj = JsonUtil.getJsonObject(jsonObj, "card"); + if (__cardObj != null) { + builder.card(Card.fromJson(__cardObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/customerEntitlement/CustomerEntitlement.java b/src/main/java/com/chargebee/v4/models/customerEntitlement/CustomerEntitlement.java index 624446ec..a531e84a 100644 --- a/src/main/java/com/chargebee/v4/models/customerEntitlement/CustomerEntitlement.java +++ b/src/main/java/com/chargebee/v4/models/customerEntitlement/CustomerEntitlement.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.customerEntitlement; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; public class CustomerEntitlement { @@ -43,19 +44,23 @@ public Boolean getIsEnabled() { } public static CustomerEntitlement fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static CustomerEntitlement fromJson(JsonObject jsonObj) { CustomerEntitlement obj = new CustomerEntitlement(); - obj.customerId = JsonUtil.getString(json, "customer_id"); + obj.customerId = JsonUtil.getString(jsonObj, "customer_id"); - obj.subscriptionId = JsonUtil.getString(json, "subscription_id"); + obj.subscriptionId = JsonUtil.getString(jsonObj, "subscription_id"); - obj.featureId = JsonUtil.getString(json, "feature_id"); + obj.featureId = JsonUtil.getString(jsonObj, "feature_id"); - obj.value = JsonUtil.getString(json, "value"); + obj.value = JsonUtil.getString(jsonObj, "value"); - obj.name = JsonUtil.getString(json, "name"); + obj.name = JsonUtil.getString(jsonObj, "name"); - obj.isEnabled = JsonUtil.getBoolean(json, "is_enabled"); + obj.isEnabled = JsonUtil.getBoolean(jsonObj, "is_enabled"); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/customerEntitlement/responses/CustomerEntitlementEntitlementsForCustomerResponse.java b/src/main/java/com/chargebee/v4/models/customerEntitlement/responses/CustomerEntitlementEntitlementsForCustomerResponse.java index 138bdb53..554bc689 100644 --- a/src/main/java/com/chargebee/v4/models/customerEntitlement/responses/CustomerEntitlementEntitlementsForCustomerResponse.java +++ b/src/main/java/com/chargebee/v4/models/customerEntitlement/responses/CustomerEntitlementEntitlementsForCustomerResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.exceptions.ChargebeeException; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; import com.chargebee.v4.services.CustomerEntitlementService; import com.chargebee.v4.models.customerEntitlement.params.CustomerEntitlementEntitlementsForCustomerParams; @@ -51,13 +52,14 @@ private CustomerEntitlementEntitlementsForCustomerResponse( */ public static CustomerEntitlementEntitlementsForCustomerResponse fromJson(String json) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(CustomerEntitlementEntitlementsForCustomerItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "list"), + CustomerEntitlementEntitlementsForCustomerItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new CustomerEntitlementEntitlementsForCustomerResponse( list, nextOffset, null, null, null, null); @@ -78,13 +80,14 @@ public static CustomerEntitlementEntitlementsForCustomerResponse fromJson( String customerId, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(CustomerEntitlementEntitlementsForCustomerItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "list"), + CustomerEntitlementEntitlementsForCustomerItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new CustomerEntitlementEntitlementsForCustomerResponse( list, nextOffset, customerId, service, originalParams, httpResponse); @@ -194,12 +197,16 @@ public CustomerEntitlement getCustomerEntitlement() { } public static CustomerEntitlementEntitlementsForCustomerItem fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static CustomerEntitlementEntitlementsForCustomerItem fromJson(JsonObject jsonObj) { CustomerEntitlementEntitlementsForCustomerItem item = new CustomerEntitlementEntitlementsForCustomerItem(); - String __customerEntitlementJson = JsonUtil.getObject(json, "customer_entitlement"); - if (__customerEntitlementJson != null) { - item.customerEntitlement = CustomerEntitlement.fromJson(__customerEntitlementJson); + JsonObject __customerEntitlementObj = JsonUtil.getJsonObject(jsonObj, "customer_entitlement"); + if (__customerEntitlementObj != null) { + item.customerEntitlement = CustomerEntitlement.fromJson(__customerEntitlementObj); } return item; diff --git a/src/main/java/com/chargebee/v4/models/differentialPrice/DifferentialPrice.java b/src/main/java/com/chargebee/v4/models/differentialPrice/DifferentialPrice.java index 7504bdb6..e56adcad 100644 --- a/src/main/java/com/chargebee/v4/models/differentialPrice/DifferentialPrice.java +++ b/src/main/java/com/chargebee/v4/models/differentialPrice/DifferentialPrice.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.differentialPrice; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import java.sql.Timestamp; import java.util.List; @@ -118,43 +119,43 @@ public static Status fromString(String value) { } public static DifferentialPrice fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static DifferentialPrice fromJson(JsonObject jsonObj) { DifferentialPrice obj = new DifferentialPrice(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.itemPriceId = JsonUtil.getString(json, "item_price_id"); + obj.itemPriceId = JsonUtil.getString(jsonObj, "item_price_id"); - obj.parentItemId = JsonUtil.getString(json, "parent_item_id"); + obj.parentItemId = JsonUtil.getString(jsonObj, "parent_item_id"); - obj.price = JsonUtil.getLong(json, "price"); + obj.price = JsonUtil.getLong(jsonObj, "price"); - obj.priceInDecimal = JsonUtil.getString(json, "price_in_decimal"); + obj.priceInDecimal = JsonUtil.getString(jsonObj, "price_in_decimal"); - obj.status = Status.fromString(JsonUtil.getString(json, "status")); + obj.status = Status.fromString(JsonUtil.getString(jsonObj, "status")); - obj.resourceVersion = JsonUtil.getLong(json, "resource_version"); + obj.resourceVersion = JsonUtil.getLong(jsonObj, "resource_version"); - obj.updatedAt = JsonUtil.getTimestamp(json, "updated_at"); + obj.updatedAt = JsonUtil.getTimestamp(jsonObj, "updated_at"); - obj.createdAt = JsonUtil.getTimestamp(json, "created_at"); + obj.createdAt = JsonUtil.getTimestamp(jsonObj, "created_at"); - obj.modifiedAt = JsonUtil.getTimestamp(json, "modified_at"); + obj.modifiedAt = JsonUtil.getTimestamp(jsonObj, "modified_at"); - obj.currencyCode = JsonUtil.getString(json, "currency_code"); + obj.currencyCode = JsonUtil.getString(jsonObj, "currency_code"); - obj.businessEntityId = JsonUtil.getString(json, "business_entity_id"); + obj.businessEntityId = JsonUtil.getString(jsonObj, "business_entity_id"); - obj.deleted = JsonUtil.getBoolean(json, "deleted"); + obj.deleted = JsonUtil.getBoolean(jsonObj, "deleted"); - obj.tiers = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "tiers")).stream() - .map(Tiers::fromJson) - .collect(java.util.stream.Collectors.toList()); + obj.tiers = JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "tiers"), Tiers::fromJson); obj.parentPeriods = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "parent_periods")).stream() - .map(ParentPeriods::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "parent_periods"), ParentPeriods::fromJson); return obj; } @@ -313,23 +314,27 @@ public static PricingType fromString(String value) { } public static Tiers fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Tiers fromJson(JsonObject jsonObj) { Tiers obj = new Tiers(); - obj.startingUnit = JsonUtil.getInteger(json, "starting_unit"); + obj.startingUnit = JsonUtil.getInteger(jsonObj, "starting_unit"); - obj.endingUnit = JsonUtil.getInteger(json, "ending_unit"); + obj.endingUnit = JsonUtil.getInteger(jsonObj, "ending_unit"); - obj.price = JsonUtil.getLong(json, "price"); + obj.price = JsonUtil.getLong(jsonObj, "price"); - obj.startingUnitInDecimal = JsonUtil.getString(json, "starting_unit_in_decimal"); + obj.startingUnitInDecimal = JsonUtil.getString(jsonObj, "starting_unit_in_decimal"); - obj.endingUnitInDecimal = JsonUtil.getString(json, "ending_unit_in_decimal"); + obj.endingUnitInDecimal = JsonUtil.getString(jsonObj, "ending_unit_in_decimal"); - obj.priceInDecimal = JsonUtil.getString(json, "price_in_decimal"); + obj.priceInDecimal = JsonUtil.getString(jsonObj, "price_in_decimal"); - obj.pricingType = PricingType.fromString(JsonUtil.getString(json, "pricing_type")); + obj.pricingType = PricingType.fromString(JsonUtil.getString(jsonObj, "pricing_type")); - obj.packageSize = JsonUtil.getInteger(json, "package_size"); + obj.packageSize = JsonUtil.getInteger(jsonObj, "package_size"); return obj; } @@ -433,17 +438,15 @@ public static PeriodUnit fromString(String value) { } public static ParentPeriods fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static ParentPeriods fromJson(JsonObject jsonObj) { ParentPeriods obj = new ParentPeriods(); - obj.periodUnit = PeriodUnit.fromString(JsonUtil.getString(json, "period_unit")); + obj.periodUnit = PeriodUnit.fromString(JsonUtil.getString(jsonObj, "period_unit")); - String __periodJson = JsonUtil.getArray(json, "period"); - obj.period = - __periodJson != null - ? JsonUtil.parseObjectArray(__periodJson).stream() - .map(JsonUtil::parseJsonObjectToMap) - .collect(java.util.stream.Collectors.toList()) - : null; + obj.period = JsonUtil.mapArrayToObjects(JsonUtil.getJsonArray(jsonObj, "period")); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/differentialPrice/responses/DifferentialPriceCreateResponse.java b/src/main/java/com/chargebee/v4/models/differentialPrice/responses/DifferentialPriceCreateResponse.java index aa239701..1deaa78c 100644 --- a/src/main/java/com/chargebee/v4/models/differentialPrice/responses/DifferentialPriceCreateResponse.java +++ b/src/main/java/com/chargebee/v4/models/differentialPrice/responses/DifferentialPriceCreateResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static DifferentialPriceCreateResponse fromJson(String json) { /** Parse JSON response into DifferentialPriceCreateResponse object with HTTP response. */ public static DifferentialPriceCreateResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __differentialPriceJson = JsonUtil.getObject(json, "differential_price"); - if (__differentialPriceJson != null) { - builder.differentialPrice(DifferentialPrice.fromJson(__differentialPriceJson)); + JsonObject __differentialPriceObj = JsonUtil.getJsonObject(jsonObj, "differential_price"); + if (__differentialPriceObj != null) { + builder.differentialPrice(DifferentialPrice.fromJson(__differentialPriceObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/differentialPrice/responses/DifferentialPriceDeleteResponse.java b/src/main/java/com/chargebee/v4/models/differentialPrice/responses/DifferentialPriceDeleteResponse.java index a4e3c5f6..ed477975 100644 --- a/src/main/java/com/chargebee/v4/models/differentialPrice/responses/DifferentialPriceDeleteResponse.java +++ b/src/main/java/com/chargebee/v4/models/differentialPrice/responses/DifferentialPriceDeleteResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static DifferentialPriceDeleteResponse fromJson(String json) { /** Parse JSON response into DifferentialPriceDeleteResponse object with HTTP response. */ public static DifferentialPriceDeleteResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __differentialPriceJson = JsonUtil.getObject(json, "differential_price"); - if (__differentialPriceJson != null) { - builder.differentialPrice(DifferentialPrice.fromJson(__differentialPriceJson)); + JsonObject __differentialPriceObj = JsonUtil.getJsonObject(jsonObj, "differential_price"); + if (__differentialPriceObj != null) { + builder.differentialPrice(DifferentialPrice.fromJson(__differentialPriceObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/differentialPrice/responses/DifferentialPriceListResponse.java b/src/main/java/com/chargebee/v4/models/differentialPrice/responses/DifferentialPriceListResponse.java index d79b8681..15b86b06 100644 --- a/src/main/java/com/chargebee/v4/models/differentialPrice/responses/DifferentialPriceListResponse.java +++ b/src/main/java/com/chargebee/v4/models/differentialPrice/responses/DifferentialPriceListResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.exceptions.ChargebeeException; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; import com.chargebee.v4.services.DifferentialPriceService; import com.chargebee.v4.models.differentialPrice.params.DifferentialPriceListParams; @@ -43,13 +44,13 @@ private DifferentialPriceListResponse( */ public static DifferentialPriceListResponse fromJson(String json) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(DifferentialPriceListItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "list"), DifferentialPriceListItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new DifferentialPriceListResponse(list, nextOffset, null, null, null); } catch (Exception e) { @@ -67,13 +68,13 @@ public static DifferentialPriceListResponse fromJson( DifferentialPriceListParams originalParams, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(DifferentialPriceListItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "list"), DifferentialPriceListItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new DifferentialPriceListResponse( list, nextOffset, service, originalParams, httpResponse); @@ -176,11 +177,15 @@ public DifferentialPrice getDifferentialPrice() { } public static DifferentialPriceListItem fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static DifferentialPriceListItem fromJson(JsonObject jsonObj) { DifferentialPriceListItem item = new DifferentialPriceListItem(); - String __differentialPriceJson = JsonUtil.getObject(json, "differential_price"); - if (__differentialPriceJson != null) { - item.differentialPrice = DifferentialPrice.fromJson(__differentialPriceJson); + JsonObject __differentialPriceObj = JsonUtil.getJsonObject(jsonObj, "differential_price"); + if (__differentialPriceObj != null) { + item.differentialPrice = DifferentialPrice.fromJson(__differentialPriceObj); } return item; diff --git a/src/main/java/com/chargebee/v4/models/differentialPrice/responses/DifferentialPriceRetrieveResponse.java b/src/main/java/com/chargebee/v4/models/differentialPrice/responses/DifferentialPriceRetrieveResponse.java index 6672cdae..a1d3b5e7 100644 --- a/src/main/java/com/chargebee/v4/models/differentialPrice/responses/DifferentialPriceRetrieveResponse.java +++ b/src/main/java/com/chargebee/v4/models/differentialPrice/responses/DifferentialPriceRetrieveResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static DifferentialPriceRetrieveResponse fromJson(String json) { /** Parse JSON response into DifferentialPriceRetrieveResponse object with HTTP response. */ public static DifferentialPriceRetrieveResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __differentialPriceJson = JsonUtil.getObject(json, "differential_price"); - if (__differentialPriceJson != null) { - builder.differentialPrice(DifferentialPrice.fromJson(__differentialPriceJson)); + JsonObject __differentialPriceObj = JsonUtil.getJsonObject(jsonObj, "differential_price"); + if (__differentialPriceObj != null) { + builder.differentialPrice(DifferentialPrice.fromJson(__differentialPriceObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/differentialPrice/responses/DifferentialPriceUpdateResponse.java b/src/main/java/com/chargebee/v4/models/differentialPrice/responses/DifferentialPriceUpdateResponse.java index d47001da..e56ed36d 100644 --- a/src/main/java/com/chargebee/v4/models/differentialPrice/responses/DifferentialPriceUpdateResponse.java +++ b/src/main/java/com/chargebee/v4/models/differentialPrice/responses/DifferentialPriceUpdateResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static DifferentialPriceUpdateResponse fromJson(String json) { /** Parse JSON response into DifferentialPriceUpdateResponse object with HTTP response. */ public static DifferentialPriceUpdateResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __differentialPriceJson = JsonUtil.getObject(json, "differential_price"); - if (__differentialPriceJson != null) { - builder.differentialPrice(DifferentialPrice.fromJson(__differentialPriceJson)); + JsonObject __differentialPriceObj = JsonUtil.getJsonObject(jsonObj, "differential_price"); + if (__differentialPriceObj != null) { + builder.differentialPrice(DifferentialPrice.fromJson(__differentialPriceObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/discount/Discount.java b/src/main/java/com/chargebee/v4/models/discount/Discount.java index f20c61f8..3a2126af 100644 --- a/src/main/java/com/chargebee/v4/models/discount/Discount.java +++ b/src/main/java/com/chargebee/v4/models/discount/Discount.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.discount; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import java.sql.Timestamp; public class Discount { @@ -224,43 +225,47 @@ public static ApplyOn fromString(String value) { } public static Discount fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Discount fromJson(JsonObject jsonObj) { Discount obj = new Discount(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.invoiceName = JsonUtil.getString(json, "invoice_name"); + obj.invoiceName = JsonUtil.getString(jsonObj, "invoice_name"); - obj.type = Type.fromString(JsonUtil.getString(json, "type")); + obj.type = Type.fromString(JsonUtil.getString(jsonObj, "type")); - obj.percentage = JsonUtil.getDouble(json, "percentage"); + obj.percentage = JsonUtil.getDouble(jsonObj, "percentage"); - obj.amount = JsonUtil.getLong(json, "amount"); + obj.amount = JsonUtil.getLong(jsonObj, "amount"); - obj.quantity = JsonUtil.getInteger(json, "quantity"); + obj.quantity = JsonUtil.getInteger(jsonObj, "quantity"); - obj.currencyCode = JsonUtil.getString(json, "currency_code"); + obj.currencyCode = JsonUtil.getString(jsonObj, "currency_code"); - obj.durationType = DurationType.fromString(JsonUtil.getString(json, "duration_type")); + obj.durationType = DurationType.fromString(JsonUtil.getString(jsonObj, "duration_type")); - obj.period = JsonUtil.getInteger(json, "period"); + obj.period = JsonUtil.getInteger(jsonObj, "period"); - obj.periodUnit = PeriodUnit.fromString(JsonUtil.getString(json, "period_unit")); + obj.periodUnit = PeriodUnit.fromString(JsonUtil.getString(jsonObj, "period_unit")); - obj.includedInMrr = JsonUtil.getBoolean(json, "included_in_mrr"); + obj.includedInMrr = JsonUtil.getBoolean(jsonObj, "included_in_mrr"); - obj.applyOn = ApplyOn.fromString(JsonUtil.getString(json, "apply_on")); + obj.applyOn = ApplyOn.fromString(JsonUtil.getString(jsonObj, "apply_on")); - obj.itemPriceId = JsonUtil.getString(json, "item_price_id"); + obj.itemPriceId = JsonUtil.getString(jsonObj, "item_price_id"); - obj.createdAt = JsonUtil.getTimestamp(json, "created_at"); + obj.createdAt = JsonUtil.getTimestamp(jsonObj, "created_at"); - obj.applyTill = JsonUtil.getTimestamp(json, "apply_till"); + obj.applyTill = JsonUtil.getTimestamp(jsonObj, "apply_till"); - obj.appliedCount = JsonUtil.getInteger(json, "applied_count"); + obj.appliedCount = JsonUtil.getInteger(jsonObj, "applied_count"); - obj.couponId = JsonUtil.getString(json, "coupon_id"); + obj.couponId = JsonUtil.getString(jsonObj, "coupon_id"); - obj.index = JsonUtil.getInteger(json, "index"); + obj.index = JsonUtil.getInteger(jsonObj, "index"); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/download/Download.java b/src/main/java/com/chargebee/v4/models/download/Download.java index f11c8639..44480cf6 100644 --- a/src/main/java/com/chargebee/v4/models/download/Download.java +++ b/src/main/java/com/chargebee/v4/models/download/Download.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.download; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import java.sql.Timestamp; public class Download { @@ -29,13 +30,17 @@ public String getMimeType() { } public static Download fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Download fromJson(JsonObject jsonObj) { Download obj = new Download(); - obj.downloadUrl = JsonUtil.getString(json, "download_url"); + obj.downloadUrl = JsonUtil.getString(jsonObj, "download_url"); - obj.validTill = JsonUtil.getTimestamp(json, "valid_till"); + obj.validTill = JsonUtil.getTimestamp(jsonObj, "valid_till"); - obj.mimeType = JsonUtil.getString(json, "mime_type"); + obj.mimeType = JsonUtil.getString(jsonObj, "mime_type"); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/einvoice/Einvoice.java b/src/main/java/com/chargebee/v4/models/einvoice/Einvoice.java index 0fed70d0..28cfe3a5 100644 --- a/src/main/java/com/chargebee/v4/models/einvoice/Einvoice.java +++ b/src/main/java/com/chargebee/v4/models/einvoice/Einvoice.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.einvoice; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; public class Einvoice { @@ -83,15 +84,19 @@ public static Status fromString(String value) { } public static Einvoice fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Einvoice fromJson(JsonObject jsonObj) { Einvoice obj = new Einvoice(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.referenceNumber = JsonUtil.getString(json, "reference_number"); + obj.referenceNumber = JsonUtil.getString(jsonObj, "reference_number"); - obj.status = Status.fromString(JsonUtil.getString(json, "status")); + obj.status = Status.fromString(JsonUtil.getString(jsonObj, "status")); - obj.message = JsonUtil.getString(json, "message"); + obj.message = JsonUtil.getString(jsonObj, "message"); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/entitlement/Entitlement.java b/src/main/java/com/chargebee/v4/models/entitlement/Entitlement.java index 1796b7b1..4b85d95e 100644 --- a/src/main/java/com/chargebee/v4/models/entitlement/Entitlement.java +++ b/src/main/java/com/chargebee/v4/models/entitlement/Entitlement.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.entitlement; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; public class Entitlement { @@ -82,21 +83,25 @@ public static EntityType fromString(String value) { } public static Entitlement fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Entitlement fromJson(JsonObject jsonObj) { Entitlement obj = new Entitlement(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.entityId = JsonUtil.getString(json, "entity_id"); + obj.entityId = JsonUtil.getString(jsonObj, "entity_id"); - obj.entityType = EntityType.fromString(JsonUtil.getString(json, "entity_type")); + obj.entityType = EntityType.fromString(JsonUtil.getString(jsonObj, "entity_type")); - obj.featureId = JsonUtil.getString(json, "feature_id"); + obj.featureId = JsonUtil.getString(jsonObj, "feature_id"); - obj.featureName = JsonUtil.getString(json, "feature_name"); + obj.featureName = JsonUtil.getString(jsonObj, "feature_name"); - obj.value = JsonUtil.getString(json, "value"); + obj.value = JsonUtil.getString(jsonObj, "value"); - obj.name = JsonUtil.getString(json, "name"); + obj.name = JsonUtil.getString(jsonObj, "name"); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/entitlement/responses/EntitlementCreateResponse.java b/src/main/java/com/chargebee/v4/models/entitlement/responses/EntitlementCreateResponse.java index b9dc91e4..bd46e346 100644 --- a/src/main/java/com/chargebee/v4/models/entitlement/responses/EntitlementCreateResponse.java +++ b/src/main/java/com/chargebee/v4/models/entitlement/responses/EntitlementCreateResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -29,12 +30,11 @@ public static EntitlementCreateResponse fromJson(String json) { /** Parse JSON response into EntitlementCreateResponse object with HTTP response. */ public static EntitlementCreateResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); builder.list( - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(Entitlement::fromJson) - .collect(java.util.stream.Collectors.toList())); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "list"), Entitlement::fromJson)); builder.httpResponse(httpResponse); return builder.build(); diff --git a/src/main/java/com/chargebee/v4/models/entitlement/responses/EntitlementListResponse.java b/src/main/java/com/chargebee/v4/models/entitlement/responses/EntitlementListResponse.java index 64e5cf72..c94d832b 100644 --- a/src/main/java/com/chargebee/v4/models/entitlement/responses/EntitlementListResponse.java +++ b/src/main/java/com/chargebee/v4/models/entitlement/responses/EntitlementListResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.exceptions.ChargebeeException; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; import com.chargebee.v4.services.EntitlementService; import com.chargebee.v4.models.entitlement.params.EntitlementListParams; @@ -43,13 +44,12 @@ private EntitlementListResponse( */ public static EntitlementListResponse fromJson(String json) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(EntitlementListItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "list"), EntitlementListItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new EntitlementListResponse(list, nextOffset, null, null, null); } catch (Exception e) { @@ -67,13 +67,12 @@ public static EntitlementListResponse fromJson( EntitlementListParams originalParams, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(EntitlementListItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "list"), EntitlementListItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new EntitlementListResponse(list, nextOffset, service, originalParams, httpResponse); } catch (Exception e) { @@ -173,11 +172,15 @@ public Entitlement getEntitlement() { } public static EntitlementListItem fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static EntitlementListItem fromJson(JsonObject jsonObj) { EntitlementListItem item = new EntitlementListItem(); - String __entitlementJson = JsonUtil.getObject(json, "entitlement"); - if (__entitlementJson != null) { - item.entitlement = Entitlement.fromJson(__entitlementJson); + JsonObject __entitlementObj = JsonUtil.getJsonObject(jsonObj, "entitlement"); + if (__entitlementObj != null) { + item.entitlement = Entitlement.fromJson(__entitlementObj); } return item; diff --git a/src/main/java/com/chargebee/v4/models/entitlementOverride/EntitlementOverride.java b/src/main/java/com/chargebee/v4/models/entitlementOverride/EntitlementOverride.java index 3955213f..3303698a 100644 --- a/src/main/java/com/chargebee/v4/models/entitlementOverride/EntitlementOverride.java +++ b/src/main/java/com/chargebee/v4/models/entitlementOverride/EntitlementOverride.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.entitlementOverride; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import java.sql.Timestamp; public class EntitlementOverride { @@ -105,31 +106,35 @@ public static ScheduleStatus fromString(String value) { } public static EntitlementOverride fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static EntitlementOverride fromJson(JsonObject jsonObj) { EntitlementOverride obj = new EntitlementOverride(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.subscriptionId = JsonUtil.getString(json, "subscription_id"); + obj.subscriptionId = JsonUtil.getString(jsonObj, "subscription_id"); - obj.entityId = JsonUtil.getString(json, "entity_id"); + obj.entityId = JsonUtil.getString(jsonObj, "entity_id"); - obj.entityType = JsonUtil.getString(json, "entity_type"); + obj.entityType = JsonUtil.getString(jsonObj, "entity_type"); - obj.featureId = JsonUtil.getString(json, "feature_id"); + obj.featureId = JsonUtil.getString(jsonObj, "feature_id"); - obj.featureName = JsonUtil.getString(json, "feature_name"); + obj.featureName = JsonUtil.getString(jsonObj, "feature_name"); - obj.value = JsonUtil.getString(json, "value"); + obj.value = JsonUtil.getString(jsonObj, "value"); - obj.name = JsonUtil.getString(json, "name"); + obj.name = JsonUtil.getString(jsonObj, "name"); - obj.expiresAt = JsonUtil.getTimestamp(json, "expires_at"); + obj.expiresAt = JsonUtil.getTimestamp(jsonObj, "expires_at"); - obj.effectiveFrom = JsonUtil.getTimestamp(json, "effective_from"); + obj.effectiveFrom = JsonUtil.getTimestamp(jsonObj, "effective_from"); - obj.isEnabled = JsonUtil.getBoolean(json, "is_enabled"); + obj.isEnabled = JsonUtil.getBoolean(jsonObj, "is_enabled"); - obj.scheduleStatus = ScheduleStatus.fromString(JsonUtil.getString(json, "schedule_status")); + obj.scheduleStatus = ScheduleStatus.fromString(JsonUtil.getString(jsonObj, "schedule_status")); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/entitlementOverride/responses/AddEntitlementOverrideForSubscriptionResponse.java b/src/main/java/com/chargebee/v4/models/entitlementOverride/responses/AddEntitlementOverrideForSubscriptionResponse.java index 7431c705..651cbecb 100644 --- a/src/main/java/com/chargebee/v4/models/entitlementOverride/responses/AddEntitlementOverrideForSubscriptionResponse.java +++ b/src/main/java/com/chargebee/v4/models/entitlementOverride/responses/AddEntitlementOverrideForSubscriptionResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -33,12 +34,11 @@ public static AddEntitlementOverrideForSubscriptionResponse fromJson(String json public static AddEntitlementOverrideForSubscriptionResponse fromJson( String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); builder.list( - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(EntitlementOverride::fromJson) - .collect(java.util.stream.Collectors.toList())); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "list"), EntitlementOverride::fromJson)); builder.httpResponse(httpResponse); return builder.build(); diff --git a/src/main/java/com/chargebee/v4/models/entitlementOverride/responses/ListEntitlementOverrideForSubscriptionResponse.java b/src/main/java/com/chargebee/v4/models/entitlementOverride/responses/ListEntitlementOverrideForSubscriptionResponse.java index eb4a71bd..f8e4a29d 100644 --- a/src/main/java/com/chargebee/v4/models/entitlementOverride/responses/ListEntitlementOverrideForSubscriptionResponse.java +++ b/src/main/java/com/chargebee/v4/models/entitlementOverride/responses/ListEntitlementOverrideForSubscriptionResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.exceptions.ChargebeeException; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; import com.chargebee.v4.services.EntitlementOverrideService; import com.chargebee.v4.models.entitlementOverride.params.ListEntitlementOverrideForSubscriptionParams; @@ -51,13 +52,14 @@ private ListEntitlementOverrideForSubscriptionResponse( */ public static ListEntitlementOverrideForSubscriptionResponse fromJson(String json) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(EntitlementOverrideListEntitlementOverrideForSubscriptionItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "list"), + EntitlementOverrideListEntitlementOverrideForSubscriptionItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new ListEntitlementOverrideForSubscriptionResponse( list, nextOffset, null, null, null, null); @@ -78,13 +80,14 @@ public static ListEntitlementOverrideForSubscriptionResponse fromJson( String subscriptionId, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(EntitlementOverrideListEntitlementOverrideForSubscriptionItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "list"), + EntitlementOverrideListEntitlementOverrideForSubscriptionItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new ListEntitlementOverrideForSubscriptionResponse( list, nextOffset, subscriptionId, service, originalParams, httpResponse); @@ -195,12 +198,17 @@ public EntitlementOverride getEntitlementOverride() { public static EntitlementOverrideListEntitlementOverrideForSubscriptionItem fromJson( String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static EntitlementOverrideListEntitlementOverrideForSubscriptionItem fromJson( + JsonObject jsonObj) { EntitlementOverrideListEntitlementOverrideForSubscriptionItem item = new EntitlementOverrideListEntitlementOverrideForSubscriptionItem(); - String __entitlementOverrideJson = JsonUtil.getObject(json, "entitlement_override"); - if (__entitlementOverrideJson != null) { - item.entitlementOverride = EntitlementOverride.fromJson(__entitlementOverrideJson); + JsonObject __entitlementOverrideObj = JsonUtil.getJsonObject(jsonObj, "entitlement_override"); + if (__entitlementOverrideObj != null) { + item.entitlementOverride = EntitlementOverride.fromJson(__entitlementOverrideObj); } return item; diff --git a/src/main/java/com/chargebee/v4/models/estimate/Estimate.java b/src/main/java/com/chargebee/v4/models/estimate/Estimate.java index 7c79f7a1..6b340655 100644 --- a/src/main/java/com/chargebee/v4/models/estimate/Estimate.java +++ b/src/main/java/com/chargebee/v4/models/estimate/Estimate.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.estimate; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import java.math.BigDecimal; import java.sql.Timestamp; import java.util.List; @@ -61,49 +62,51 @@ public List getUnbilledChargeEstimates() { } public static Estimate fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Estimate fromJson(JsonObject jsonObj) { Estimate obj = new Estimate(); - obj.createdAt = JsonUtil.getTimestamp(json, "created_at"); + obj.createdAt = JsonUtil.getTimestamp(jsonObj, "created_at"); - String __subscriptionEstimateJson = JsonUtil.getObject(json, "subscription_estimate"); - if (__subscriptionEstimateJson != null) { - obj.subscriptionEstimate = SubscriptionEstimate.fromJson(__subscriptionEstimateJson); + JsonObject __subscriptionEstimateObj = JsonUtil.getJsonObject(jsonObj, "subscription_estimate"); + if (__subscriptionEstimateObj != null) { + obj.subscriptionEstimate = SubscriptionEstimate.fromJson(__subscriptionEstimateObj); } obj.subscriptionEstimates = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "subscription_estimates")).stream() - .map(SubscriptionEstimates::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "subscription_estimates"), + SubscriptionEstimates::fromJson); - String __invoiceEstimateJson = JsonUtil.getObject(json, "invoice_estimate"); - if (__invoiceEstimateJson != null) { - obj.invoiceEstimate = InvoiceEstimate.fromJson(__invoiceEstimateJson); + JsonObject __invoiceEstimateObj = JsonUtil.getJsonObject(jsonObj, "invoice_estimate"); + if (__invoiceEstimateObj != null) { + obj.invoiceEstimate = InvoiceEstimate.fromJson(__invoiceEstimateObj); } obj.invoiceEstimates = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "invoice_estimates")).stream() - .map(InvoiceEstimates::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "invoice_estimates"), InvoiceEstimates::fromJson); obj.paymentScheduleEstimates = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "payment_schedule_estimates")).stream() - .map(PaymentScheduleEstimates::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "payment_schedule_estimates"), + PaymentScheduleEstimates::fromJson); - String __nextInvoiceEstimateJson = JsonUtil.getObject(json, "next_invoice_estimate"); - if (__nextInvoiceEstimateJson != null) { - obj.nextInvoiceEstimate = NextInvoiceEstimate.fromJson(__nextInvoiceEstimateJson); + JsonObject __nextInvoiceEstimateObj = JsonUtil.getJsonObject(jsonObj, "next_invoice_estimate"); + if (__nextInvoiceEstimateObj != null) { + obj.nextInvoiceEstimate = NextInvoiceEstimate.fromJson(__nextInvoiceEstimateObj); } obj.creditNoteEstimates = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "credit_note_estimates")).stream() - .map(CreditNoteEstimates::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "credit_note_estimates"), CreditNoteEstimates::fromJson); obj.unbilledChargeEstimates = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "unbilled_charge_estimates")).stream() - .map(UnbilledChargeEstimates::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "unbilled_charge_estimates"), + UnbilledChargeEstimates::fromJson); return obj; } @@ -283,30 +286,35 @@ public static TrialEndAction fromString(String value) { } public static SubscriptionEstimate fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static SubscriptionEstimate fromJson(JsonObject jsonObj) { SubscriptionEstimate obj = new SubscriptionEstimate(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.currencyCode = JsonUtil.getString(json, "currency_code"); + obj.currencyCode = JsonUtil.getString(jsonObj, "currency_code"); - obj.status = Status.fromString(JsonUtil.getString(json, "status")); + obj.status = Status.fromString(JsonUtil.getString(jsonObj, "status")); - obj.trialEndAction = TrialEndAction.fromString(JsonUtil.getString(json, "trial_end_action")); + obj.trialEndAction = + TrialEndAction.fromString(JsonUtil.getString(jsonObj, "trial_end_action")); - obj.nextBillingAt = JsonUtil.getTimestamp(json, "next_billing_at"); + obj.nextBillingAt = JsonUtil.getTimestamp(jsonObj, "next_billing_at"); - obj.pauseDate = JsonUtil.getTimestamp(json, "pause_date"); + obj.pauseDate = JsonUtil.getTimestamp(jsonObj, "pause_date"); - obj.resumeDate = JsonUtil.getTimestamp(json, "resume_date"); + obj.resumeDate = JsonUtil.getTimestamp(jsonObj, "resume_date"); - String __shippingAddressJson = JsonUtil.getObject(json, "shipping_address"); - if (__shippingAddressJson != null) { - obj.shippingAddress = ShippingAddress.fromJson(__shippingAddressJson); + JsonObject __shippingAddressObj = JsonUtil.getJsonObject(jsonObj, "shipping_address"); + if (__shippingAddressObj != null) { + obj.shippingAddress = ShippingAddress.fromJson(__shippingAddressObj); } - String __contractTermJson = JsonUtil.getObject(json, "contract_term"); - if (__contractTermJson != null) { - obj.contractTerm = ContractTerm.fromJson(__contractTermJson); + JsonObject __contractTermObj = JsonUtil.getJsonObject(jsonObj, "contract_term"); + if (__contractTermObj != null) { + obj.contractTerm = ContractTerm.fromJson(__contractTermObj); } return obj; @@ -476,36 +484,40 @@ public static ValidationStatus fromString(String value) { } public static ShippingAddress fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static ShippingAddress fromJson(JsonObject jsonObj) { ShippingAddress obj = new ShippingAddress(); - obj.firstName = JsonUtil.getString(json, "first_name"); + obj.firstName = JsonUtil.getString(jsonObj, "first_name"); - obj.lastName = JsonUtil.getString(json, "last_name"); + obj.lastName = JsonUtil.getString(jsonObj, "last_name"); - obj.email = JsonUtil.getString(json, "email"); + obj.email = JsonUtil.getString(jsonObj, "email"); - obj.company = JsonUtil.getString(json, "company"); + obj.company = JsonUtil.getString(jsonObj, "company"); - obj.phone = JsonUtil.getString(json, "phone"); + obj.phone = JsonUtil.getString(jsonObj, "phone"); - obj.line1 = JsonUtil.getString(json, "line1"); + obj.line1 = JsonUtil.getString(jsonObj, "line1"); - obj.line2 = JsonUtil.getString(json, "line2"); + obj.line2 = JsonUtil.getString(jsonObj, "line2"); - obj.line3 = JsonUtil.getString(json, "line3"); + obj.line3 = JsonUtil.getString(jsonObj, "line3"); - obj.city = JsonUtil.getString(json, "city"); + obj.city = JsonUtil.getString(jsonObj, "city"); - obj.stateCode = JsonUtil.getString(json, "state_code"); + obj.stateCode = JsonUtil.getString(jsonObj, "state_code"); - obj.state = JsonUtil.getString(json, "state"); + obj.state = JsonUtil.getString(jsonObj, "state"); - obj.country = JsonUtil.getString(json, "country"); + obj.country = JsonUtil.getString(jsonObj, "country"); - obj.zip = JsonUtil.getString(json, "zip"); + obj.zip = JsonUtil.getString(jsonObj, "zip"); obj.validationStatus = - ValidationStatus.fromString(JsonUtil.getString(json, "validation_status")); + ValidationStatus.fromString(JsonUtil.getString(jsonObj, "validation_status")); return obj; } @@ -717,32 +729,37 @@ public static ActionAtTermEnd fromString(String value) { } public static ContractTerm fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static ContractTerm fromJson(JsonObject jsonObj) { ContractTerm obj = new ContractTerm(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.status = Status.fromString(JsonUtil.getString(json, "status")); + obj.status = Status.fromString(JsonUtil.getString(jsonObj, "status")); - obj.contractStart = JsonUtil.getTimestamp(json, "contract_start"); + obj.contractStart = JsonUtil.getTimestamp(jsonObj, "contract_start"); - obj.contractEnd = JsonUtil.getTimestamp(json, "contract_end"); + obj.contractEnd = JsonUtil.getTimestamp(jsonObj, "contract_end"); - obj.billingCycle = JsonUtil.getInteger(json, "billing_cycle"); + obj.billingCycle = JsonUtil.getInteger(jsonObj, "billing_cycle"); obj.actionAtTermEnd = - ActionAtTermEnd.fromString(JsonUtil.getString(json, "action_at_term_end")); + ActionAtTermEnd.fromString(JsonUtil.getString(jsonObj, "action_at_term_end")); - obj.totalContractValue = JsonUtil.getLong(json, "total_contract_value"); + obj.totalContractValue = JsonUtil.getLong(jsonObj, "total_contract_value"); - obj.totalContractValueBeforeTax = JsonUtil.getLong(json, "total_contract_value_before_tax"); + obj.totalContractValueBeforeTax = + JsonUtil.getLong(jsonObj, "total_contract_value_before_tax"); - obj.cancellationCutoffPeriod = JsonUtil.getInteger(json, "cancellation_cutoff_period"); + obj.cancellationCutoffPeriod = JsonUtil.getInteger(jsonObj, "cancellation_cutoff_period"); - obj.createdAt = JsonUtil.getTimestamp(json, "created_at"); + obj.createdAt = JsonUtil.getTimestamp(jsonObj, "created_at"); - obj.subscriptionId = JsonUtil.getString(json, "subscription_id"); + obj.subscriptionId = JsonUtil.getString(jsonObj, "subscription_id"); - obj.remainingBillingCycles = JsonUtil.getInteger(json, "remaining_billing_cycles"); + obj.remainingBillingCycles = JsonUtil.getInteger(jsonObj, "remaining_billing_cycles"); return obj; } @@ -937,30 +954,35 @@ public static TrialEndAction fromString(String value) { } public static SubscriptionEstimates fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static SubscriptionEstimates fromJson(JsonObject jsonObj) { SubscriptionEstimates obj = new SubscriptionEstimates(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.currencyCode = JsonUtil.getString(json, "currency_code"); + obj.currencyCode = JsonUtil.getString(jsonObj, "currency_code"); - obj.status = Status.fromString(JsonUtil.getString(json, "status")); + obj.status = Status.fromString(JsonUtil.getString(jsonObj, "status")); - obj.trialEndAction = TrialEndAction.fromString(JsonUtil.getString(json, "trial_end_action")); + obj.trialEndAction = + TrialEndAction.fromString(JsonUtil.getString(jsonObj, "trial_end_action")); - obj.nextBillingAt = JsonUtil.getTimestamp(json, "next_billing_at"); + obj.nextBillingAt = JsonUtil.getTimestamp(jsonObj, "next_billing_at"); - obj.pauseDate = JsonUtil.getTimestamp(json, "pause_date"); + obj.pauseDate = JsonUtil.getTimestamp(jsonObj, "pause_date"); - obj.resumeDate = JsonUtil.getTimestamp(json, "resume_date"); + obj.resumeDate = JsonUtil.getTimestamp(jsonObj, "resume_date"); - String __shippingAddressJson = JsonUtil.getObject(json, "shipping_address"); - if (__shippingAddressJson != null) { - obj.shippingAddress = ShippingAddress.fromJson(__shippingAddressJson); + JsonObject __shippingAddressObj = JsonUtil.getJsonObject(jsonObj, "shipping_address"); + if (__shippingAddressObj != null) { + obj.shippingAddress = ShippingAddress.fromJson(__shippingAddressObj); } - String __contractTermJson = JsonUtil.getObject(json, "contract_term"); - if (__contractTermJson != null) { - obj.contractTerm = ContractTerm.fromJson(__contractTermJson); + JsonObject __contractTermObj = JsonUtil.getJsonObject(jsonObj, "contract_term"); + if (__contractTermObj != null) { + obj.contractTerm = ContractTerm.fromJson(__contractTermObj); } return obj; @@ -1130,36 +1152,40 @@ public static ValidationStatus fromString(String value) { } public static ShippingAddress fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static ShippingAddress fromJson(JsonObject jsonObj) { ShippingAddress obj = new ShippingAddress(); - obj.firstName = JsonUtil.getString(json, "first_name"); + obj.firstName = JsonUtil.getString(jsonObj, "first_name"); - obj.lastName = JsonUtil.getString(json, "last_name"); + obj.lastName = JsonUtil.getString(jsonObj, "last_name"); - obj.email = JsonUtil.getString(json, "email"); + obj.email = JsonUtil.getString(jsonObj, "email"); - obj.company = JsonUtil.getString(json, "company"); + obj.company = JsonUtil.getString(jsonObj, "company"); - obj.phone = JsonUtil.getString(json, "phone"); + obj.phone = JsonUtil.getString(jsonObj, "phone"); - obj.line1 = JsonUtil.getString(json, "line1"); + obj.line1 = JsonUtil.getString(jsonObj, "line1"); - obj.line2 = JsonUtil.getString(json, "line2"); + obj.line2 = JsonUtil.getString(jsonObj, "line2"); - obj.line3 = JsonUtil.getString(json, "line3"); + obj.line3 = JsonUtil.getString(jsonObj, "line3"); - obj.city = JsonUtil.getString(json, "city"); + obj.city = JsonUtil.getString(jsonObj, "city"); - obj.stateCode = JsonUtil.getString(json, "state_code"); + obj.stateCode = JsonUtil.getString(jsonObj, "state_code"); - obj.state = JsonUtil.getString(json, "state"); + obj.state = JsonUtil.getString(jsonObj, "state"); - obj.country = JsonUtil.getString(json, "country"); + obj.country = JsonUtil.getString(jsonObj, "country"); - obj.zip = JsonUtil.getString(json, "zip"); + obj.zip = JsonUtil.getString(jsonObj, "zip"); obj.validationStatus = - ValidationStatus.fromString(JsonUtil.getString(json, "validation_status")); + ValidationStatus.fromString(JsonUtil.getString(jsonObj, "validation_status")); return obj; } @@ -1371,32 +1397,37 @@ public static ActionAtTermEnd fromString(String value) { } public static ContractTerm fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static ContractTerm fromJson(JsonObject jsonObj) { ContractTerm obj = new ContractTerm(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.status = Status.fromString(JsonUtil.getString(json, "status")); + obj.status = Status.fromString(JsonUtil.getString(jsonObj, "status")); - obj.contractStart = JsonUtil.getTimestamp(json, "contract_start"); + obj.contractStart = JsonUtil.getTimestamp(jsonObj, "contract_start"); - obj.contractEnd = JsonUtil.getTimestamp(json, "contract_end"); + obj.contractEnd = JsonUtil.getTimestamp(jsonObj, "contract_end"); - obj.billingCycle = JsonUtil.getInteger(json, "billing_cycle"); + obj.billingCycle = JsonUtil.getInteger(jsonObj, "billing_cycle"); obj.actionAtTermEnd = - ActionAtTermEnd.fromString(JsonUtil.getString(json, "action_at_term_end")); + ActionAtTermEnd.fromString(JsonUtil.getString(jsonObj, "action_at_term_end")); - obj.totalContractValue = JsonUtil.getLong(json, "total_contract_value"); + obj.totalContractValue = JsonUtil.getLong(jsonObj, "total_contract_value"); - obj.totalContractValueBeforeTax = JsonUtil.getLong(json, "total_contract_value_before_tax"); + obj.totalContractValueBeforeTax = + JsonUtil.getLong(jsonObj, "total_contract_value_before_tax"); - obj.cancellationCutoffPeriod = JsonUtil.getInteger(json, "cancellation_cutoff_period"); + obj.cancellationCutoffPeriod = JsonUtil.getInteger(jsonObj, "cancellation_cutoff_period"); - obj.createdAt = JsonUtil.getTimestamp(json, "created_at"); + obj.createdAt = JsonUtil.getTimestamp(jsonObj, "created_at"); - obj.subscriptionId = JsonUtil.getString(json, "subscription_id"); + obj.subscriptionId = JsonUtil.getString(jsonObj, "subscription_id"); - obj.remainingBillingCycles = JsonUtil.getInteger(json, "remaining_billing_cycles"); + obj.remainingBillingCycles = JsonUtil.getInteger(jsonObj, "remaining_billing_cycles"); return obj; } @@ -1594,67 +1625,59 @@ public static PriceType fromString(String value) { } public static InvoiceEstimate fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static InvoiceEstimate fromJson(JsonObject jsonObj) { InvoiceEstimate obj = new InvoiceEstimate(); - obj.recurring = JsonUtil.getBoolean(json, "recurring"); + obj.recurring = JsonUtil.getBoolean(jsonObj, "recurring"); - obj.priceType = PriceType.fromString(JsonUtil.getString(json, "price_type")); + obj.priceType = PriceType.fromString(JsonUtil.getString(jsonObj, "price_type")); - obj.currencyCode = JsonUtil.getString(json, "currency_code"); + obj.currencyCode = JsonUtil.getString(jsonObj, "currency_code"); - obj.subTotal = JsonUtil.getLong(json, "sub_total"); + obj.subTotal = JsonUtil.getLong(jsonObj, "sub_total"); - obj.total = JsonUtil.getLong(json, "total"); + obj.total = JsonUtil.getLong(jsonObj, "total"); - obj.creditsApplied = JsonUtil.getLong(json, "credits_applied"); + obj.creditsApplied = JsonUtil.getLong(jsonObj, "credits_applied"); - obj.amountPaid = JsonUtil.getLong(json, "amount_paid"); + obj.amountPaid = JsonUtil.getLong(jsonObj, "amount_paid"); - obj.amountDue = JsonUtil.getLong(json, "amount_due"); + obj.amountDue = JsonUtil.getLong(jsonObj, "amount_due"); obj.lineItems = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "line_items")).stream() - .map(LineItems::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "line_items"), LineItems::fromJson); obj.lineItemTiers = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "line_item_tiers")).stream() - .map(LineItemTiers::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "line_item_tiers"), LineItemTiers::fromJson); obj.lineItemDiscounts = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "line_item_discounts")).stream() - .map(LineItemDiscounts::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "line_item_discounts"), LineItemDiscounts::fromJson); obj.lineItemTaxes = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "line_item_taxes")).stream() - .map(LineItemTaxes::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "line_item_taxes"), LineItemTaxes::fromJson); obj.lineItemCredits = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "line_item_credits")).stream() - .map(LineItemCredits::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "line_item_credits"), LineItemCredits::fromJson); obj.lineItemAddresses = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "line_item_addresses")).stream() - .map(LineItemAddresses::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "line_item_addresses"), LineItemAddresses::fromJson); obj.discounts = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "discounts")).stream() - .map(Discounts::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "discounts"), Discounts::fromJson); - obj.taxes = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "taxes")).stream() - .map(Taxes::fromJson) - .collect(java.util.stream.Collectors.toList()); + obj.taxes = JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "taxes"), Taxes::fromJson); - obj.roundOffAmount = JsonUtil.getLong(json, "round_off_amount"); + obj.roundOffAmount = JsonUtil.getLong(jsonObj, "round_off_amount"); - obj.customerId = JsonUtil.getString(json, "customer_id"); + obj.customerId = JsonUtil.getString(jsonObj, "customer_id"); return obj; } @@ -1998,58 +2021,62 @@ public static TaxExemptReason fromString(String value) { } public static LineItems fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static LineItems fromJson(JsonObject jsonObj) { LineItems obj = new LineItems(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.subscriptionId = JsonUtil.getString(json, "subscription_id"); + obj.subscriptionId = JsonUtil.getString(jsonObj, "subscription_id"); - obj.dateFrom = JsonUtil.getTimestamp(json, "date_from"); + obj.dateFrom = JsonUtil.getTimestamp(jsonObj, "date_from"); - obj.dateTo = JsonUtil.getTimestamp(json, "date_to"); + obj.dateTo = JsonUtil.getTimestamp(jsonObj, "date_to"); - obj.unitAmount = JsonUtil.getLong(json, "unit_amount"); + obj.unitAmount = JsonUtil.getLong(jsonObj, "unit_amount"); - obj.quantity = JsonUtil.getInteger(json, "quantity"); + obj.quantity = JsonUtil.getInteger(jsonObj, "quantity"); - obj.amount = JsonUtil.getLong(json, "amount"); + obj.amount = JsonUtil.getLong(jsonObj, "amount"); - obj.pricingModel = PricingModel.fromString(JsonUtil.getString(json, "pricing_model")); + obj.pricingModel = PricingModel.fromString(JsonUtil.getString(jsonObj, "pricing_model")); - obj.isTaxed = JsonUtil.getBoolean(json, "is_taxed"); + obj.isTaxed = JsonUtil.getBoolean(jsonObj, "is_taxed"); - obj.taxAmount = JsonUtil.getLong(json, "tax_amount"); + obj.taxAmount = JsonUtil.getLong(jsonObj, "tax_amount"); - obj.taxRate = JsonUtil.getDouble(json, "tax_rate"); + obj.taxRate = JsonUtil.getDouble(jsonObj, "tax_rate"); - obj.unitAmountInDecimal = JsonUtil.getString(json, "unit_amount_in_decimal"); + obj.unitAmountInDecimal = JsonUtil.getString(jsonObj, "unit_amount_in_decimal"); - obj.quantityInDecimal = JsonUtil.getString(json, "quantity_in_decimal"); + obj.quantityInDecimal = JsonUtil.getString(jsonObj, "quantity_in_decimal"); - obj.amountInDecimal = JsonUtil.getString(json, "amount_in_decimal"); + obj.amountInDecimal = JsonUtil.getString(jsonObj, "amount_in_decimal"); - obj.discountAmount = JsonUtil.getLong(json, "discount_amount"); + obj.discountAmount = JsonUtil.getLong(jsonObj, "discount_amount"); - obj.itemLevelDiscountAmount = JsonUtil.getLong(json, "item_level_discount_amount"); + obj.itemLevelDiscountAmount = JsonUtil.getLong(jsonObj, "item_level_discount_amount"); - obj.metered = JsonUtil.getBoolean(json, "metered"); + obj.metered = JsonUtil.getBoolean(jsonObj, "metered"); - obj.isPercentagePricing = JsonUtil.getBoolean(json, "is_percentage_pricing"); + obj.isPercentagePricing = JsonUtil.getBoolean(jsonObj, "is_percentage_pricing"); - obj.referenceLineItemId = JsonUtil.getString(json, "reference_line_item_id"); + obj.referenceLineItemId = JsonUtil.getString(jsonObj, "reference_line_item_id"); - obj.description = JsonUtil.getString(json, "description"); + obj.description = JsonUtil.getString(jsonObj, "description"); - obj.entityDescription = JsonUtil.getString(json, "entity_description"); + obj.entityDescription = JsonUtil.getString(jsonObj, "entity_description"); - obj.entityType = EntityType.fromString(JsonUtil.getString(json, "entity_type")); + obj.entityType = EntityType.fromString(JsonUtil.getString(jsonObj, "entity_type")); obj.taxExemptReason = - TaxExemptReason.fromString(JsonUtil.getString(json, "tax_exempt_reason")); + TaxExemptReason.fromString(JsonUtil.getString(jsonObj, "tax_exempt_reason")); - obj.entityId = JsonUtil.getString(json, "entity_id"); + obj.entityId = JsonUtil.getString(jsonObj, "entity_id"); - obj.customerId = JsonUtil.getString(json, "customer_id"); + obj.customerId = JsonUtil.getString(jsonObj, "customer_id"); return obj; } @@ -2264,29 +2291,33 @@ public static PricingType fromString(String value) { } public static LineItemTiers fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static LineItemTiers fromJson(JsonObject jsonObj) { LineItemTiers obj = new LineItemTiers(); - obj.lineItemId = JsonUtil.getString(json, "line_item_id"); + obj.lineItemId = JsonUtil.getString(jsonObj, "line_item_id"); - obj.startingUnit = JsonUtil.getInteger(json, "starting_unit"); + obj.startingUnit = JsonUtil.getInteger(jsonObj, "starting_unit"); - obj.endingUnit = JsonUtil.getInteger(json, "ending_unit"); + obj.endingUnit = JsonUtil.getInteger(jsonObj, "ending_unit"); - obj.quantityUsed = JsonUtil.getInteger(json, "quantity_used"); + obj.quantityUsed = JsonUtil.getInteger(jsonObj, "quantity_used"); - obj.unitAmount = JsonUtil.getLong(json, "unit_amount"); + obj.unitAmount = JsonUtil.getLong(jsonObj, "unit_amount"); - obj.startingUnitInDecimal = JsonUtil.getString(json, "starting_unit_in_decimal"); + obj.startingUnitInDecimal = JsonUtil.getString(jsonObj, "starting_unit_in_decimal"); - obj.endingUnitInDecimal = JsonUtil.getString(json, "ending_unit_in_decimal"); + obj.endingUnitInDecimal = JsonUtil.getString(jsonObj, "ending_unit_in_decimal"); - obj.quantityUsedInDecimal = JsonUtil.getString(json, "quantity_used_in_decimal"); + obj.quantityUsedInDecimal = JsonUtil.getString(jsonObj, "quantity_used_in_decimal"); - obj.unitAmountInDecimal = JsonUtil.getString(json, "unit_amount_in_decimal"); + obj.unitAmountInDecimal = JsonUtil.getString(jsonObj, "unit_amount_in_decimal"); - obj.pricingType = PricingType.fromString(JsonUtil.getString(json, "pricing_type")); + obj.pricingType = PricingType.fromString(JsonUtil.getString(jsonObj, "pricing_type")); - obj.packageSize = JsonUtil.getInteger(json, "package_size"); + obj.packageSize = JsonUtil.getInteger(jsonObj, "package_size"); return obj; } @@ -2421,17 +2452,21 @@ public static DiscountType fromString(String value) { } public static LineItemDiscounts fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static LineItemDiscounts fromJson(JsonObject jsonObj) { LineItemDiscounts obj = new LineItemDiscounts(); - obj.lineItemId = JsonUtil.getString(json, "line_item_id"); + obj.lineItemId = JsonUtil.getString(jsonObj, "line_item_id"); - obj.discountType = DiscountType.fromString(JsonUtil.getString(json, "discount_type")); + obj.discountType = DiscountType.fromString(JsonUtil.getString(jsonObj, "discount_type")); - obj.couponId = JsonUtil.getString(json, "coupon_id"); + obj.couponId = JsonUtil.getString(jsonObj, "coupon_id"); - obj.entityId = JsonUtil.getString(json, "entity_id"); + obj.entityId = JsonUtil.getString(jsonObj, "entity_id"); - obj.discountAmount = JsonUtil.getLong(json, "discount_amount"); + obj.discountAmount = JsonUtil.getLong(jsonObj, "discount_amount"); return obj; } @@ -2591,37 +2626,41 @@ public static TaxJurisType fromString(String value) { } public static LineItemTaxes fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static LineItemTaxes fromJson(JsonObject jsonObj) { LineItemTaxes obj = new LineItemTaxes(); - obj.lineItemId = JsonUtil.getString(json, "line_item_id"); + obj.lineItemId = JsonUtil.getString(jsonObj, "line_item_id"); - obj.taxName = JsonUtil.getString(json, "tax_name"); + obj.taxName = JsonUtil.getString(jsonObj, "tax_name"); - obj.taxRate = JsonUtil.getDouble(json, "tax_rate"); + obj.taxRate = JsonUtil.getDouble(jsonObj, "tax_rate"); - obj.dateTo = JsonUtil.getTimestamp(json, "date_to"); + obj.dateTo = JsonUtil.getTimestamp(jsonObj, "date_to"); - obj.dateFrom = JsonUtil.getTimestamp(json, "date_from"); + obj.dateFrom = JsonUtil.getTimestamp(jsonObj, "date_from"); - obj.proratedTaxableAmount = JsonUtil.getBigDecimal(json, "prorated_taxable_amount"); + obj.proratedTaxableAmount = JsonUtil.getBigDecimal(jsonObj, "prorated_taxable_amount"); - obj.isPartialTaxApplied = JsonUtil.getBoolean(json, "is_partial_tax_applied"); + obj.isPartialTaxApplied = JsonUtil.getBoolean(jsonObj, "is_partial_tax_applied"); - obj.isNonComplianceTax = JsonUtil.getBoolean(json, "is_non_compliance_tax"); + obj.isNonComplianceTax = JsonUtil.getBoolean(jsonObj, "is_non_compliance_tax"); - obj.taxableAmount = JsonUtil.getLong(json, "taxable_amount"); + obj.taxableAmount = JsonUtil.getLong(jsonObj, "taxable_amount"); - obj.taxAmount = JsonUtil.getLong(json, "tax_amount"); + obj.taxAmount = JsonUtil.getLong(jsonObj, "tax_amount"); - obj.taxJurisType = TaxJurisType.fromString(JsonUtil.getString(json, "tax_juris_type")); + obj.taxJurisType = TaxJurisType.fromString(JsonUtil.getString(jsonObj, "tax_juris_type")); - obj.taxJurisName = JsonUtil.getString(json, "tax_juris_name"); + obj.taxJurisName = JsonUtil.getString(jsonObj, "tax_juris_name"); - obj.taxJurisCode = JsonUtil.getString(json, "tax_juris_code"); + obj.taxJurisCode = JsonUtil.getString(jsonObj, "tax_juris_code"); - obj.taxAmountInLocalCurrency = JsonUtil.getLong(json, "tax_amount_in_local_currency"); + obj.taxAmountInLocalCurrency = JsonUtil.getLong(jsonObj, "tax_amount_in_local_currency"); - obj.localCurrencyCode = JsonUtil.getString(json, "local_currency_code"); + obj.localCurrencyCode = JsonUtil.getString(jsonObj, "local_currency_code"); return obj; } @@ -2726,13 +2765,17 @@ public String getLineItemId() { } public static LineItemCredits fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static LineItemCredits fromJson(JsonObject jsonObj) { LineItemCredits obj = new LineItemCredits(); - obj.cnId = JsonUtil.getString(json, "cn_id"); + obj.cnId = JsonUtil.getString(jsonObj, "cn_id"); - obj.appliedAmount = JsonUtil.getDouble(json, "applied_amount"); + obj.appliedAmount = JsonUtil.getDouble(jsonObj, "applied_amount"); - obj.lineItemId = JsonUtil.getString(json, "line_item_id"); + obj.lineItemId = JsonUtil.getString(jsonObj, "line_item_id"); return obj; } @@ -2880,38 +2923,42 @@ public static ValidationStatus fromString(String value) { } public static LineItemAddresses fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static LineItemAddresses fromJson(JsonObject jsonObj) { LineItemAddresses obj = new LineItemAddresses(); - obj.lineItemId = JsonUtil.getString(json, "line_item_id"); + obj.lineItemId = JsonUtil.getString(jsonObj, "line_item_id"); - obj.firstName = JsonUtil.getString(json, "first_name"); + obj.firstName = JsonUtil.getString(jsonObj, "first_name"); - obj.lastName = JsonUtil.getString(json, "last_name"); + obj.lastName = JsonUtil.getString(jsonObj, "last_name"); - obj.email = JsonUtil.getString(json, "email"); + obj.email = JsonUtil.getString(jsonObj, "email"); - obj.company = JsonUtil.getString(json, "company"); + obj.company = JsonUtil.getString(jsonObj, "company"); - obj.phone = JsonUtil.getString(json, "phone"); + obj.phone = JsonUtil.getString(jsonObj, "phone"); - obj.line1 = JsonUtil.getString(json, "line1"); + obj.line1 = JsonUtil.getString(jsonObj, "line1"); - obj.line2 = JsonUtil.getString(json, "line2"); + obj.line2 = JsonUtil.getString(jsonObj, "line2"); - obj.line3 = JsonUtil.getString(json, "line3"); + obj.line3 = JsonUtil.getString(jsonObj, "line3"); - obj.city = JsonUtil.getString(json, "city"); + obj.city = JsonUtil.getString(jsonObj, "city"); - obj.stateCode = JsonUtil.getString(json, "state_code"); + obj.stateCode = JsonUtil.getString(jsonObj, "state_code"); - obj.state = JsonUtil.getString(json, "state"); + obj.state = JsonUtil.getString(jsonObj, "state"); - obj.country = JsonUtil.getString(json, "country"); + obj.country = JsonUtil.getString(jsonObj, "country"); - obj.zip = JsonUtil.getString(json, "zip"); + obj.zip = JsonUtil.getString(jsonObj, "zip"); obj.validationStatus = - ValidationStatus.fromString(JsonUtil.getString(json, "validation_status")); + ValidationStatus.fromString(JsonUtil.getString(jsonObj, "validation_status")); return obj; } @@ -3100,21 +3147,25 @@ public static DiscountType fromString(String value) { } public static Discounts fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Discounts fromJson(JsonObject jsonObj) { Discounts obj = new Discounts(); - obj.amount = JsonUtil.getLong(json, "amount"); + obj.amount = JsonUtil.getLong(jsonObj, "amount"); - obj.description = JsonUtil.getString(json, "description"); + obj.description = JsonUtil.getString(jsonObj, "description"); - obj.lineItemId = JsonUtil.getString(json, "line_item_id"); + obj.lineItemId = JsonUtil.getString(jsonObj, "line_item_id"); - obj.entityType = EntityType.fromString(JsonUtil.getString(json, "entity_type")); + obj.entityType = EntityType.fromString(JsonUtil.getString(jsonObj, "entity_type")); - obj.discountType = DiscountType.fromString(JsonUtil.getString(json, "discount_type")); + obj.discountType = DiscountType.fromString(JsonUtil.getString(jsonObj, "discount_type")); - obj.entityId = JsonUtil.getString(json, "entity_id"); + obj.entityId = JsonUtil.getString(jsonObj, "entity_id"); - obj.couponSetCode = JsonUtil.getString(json, "coupon_set_code"); + obj.couponSetCode = JsonUtil.getString(jsonObj, "coupon_set_code"); return obj; } @@ -3181,13 +3232,17 @@ public String getDescription() { } public static Taxes fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Taxes fromJson(JsonObject jsonObj) { Taxes obj = new Taxes(); - obj.name = JsonUtil.getString(json, "name"); + obj.name = JsonUtil.getString(jsonObj, "name"); - obj.amount = JsonUtil.getLong(json, "amount"); + obj.amount = JsonUtil.getLong(jsonObj, "amount"); - obj.description = JsonUtil.getString(json, "description"); + obj.description = JsonUtil.getString(jsonObj, "description"); return obj; } @@ -3345,67 +3400,59 @@ public static PriceType fromString(String value) { } public static InvoiceEstimates fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static InvoiceEstimates fromJson(JsonObject jsonObj) { InvoiceEstimates obj = new InvoiceEstimates(); - obj.recurring = JsonUtil.getBoolean(json, "recurring"); + obj.recurring = JsonUtil.getBoolean(jsonObj, "recurring"); - obj.priceType = PriceType.fromString(JsonUtil.getString(json, "price_type")); + obj.priceType = PriceType.fromString(JsonUtil.getString(jsonObj, "price_type")); - obj.currencyCode = JsonUtil.getString(json, "currency_code"); + obj.currencyCode = JsonUtil.getString(jsonObj, "currency_code"); - obj.subTotal = JsonUtil.getLong(json, "sub_total"); + obj.subTotal = JsonUtil.getLong(jsonObj, "sub_total"); - obj.total = JsonUtil.getLong(json, "total"); + obj.total = JsonUtil.getLong(jsonObj, "total"); - obj.creditsApplied = JsonUtil.getLong(json, "credits_applied"); + obj.creditsApplied = JsonUtil.getLong(jsonObj, "credits_applied"); - obj.amountPaid = JsonUtil.getLong(json, "amount_paid"); + obj.amountPaid = JsonUtil.getLong(jsonObj, "amount_paid"); - obj.amountDue = JsonUtil.getLong(json, "amount_due"); + obj.amountDue = JsonUtil.getLong(jsonObj, "amount_due"); obj.lineItems = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "line_items")).stream() - .map(LineItems::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "line_items"), LineItems::fromJson); obj.lineItemTiers = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "line_item_tiers")).stream() - .map(LineItemTiers::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "line_item_tiers"), LineItemTiers::fromJson); obj.lineItemDiscounts = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "line_item_discounts")).stream() - .map(LineItemDiscounts::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "line_item_discounts"), LineItemDiscounts::fromJson); obj.lineItemTaxes = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "line_item_taxes")).stream() - .map(LineItemTaxes::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "line_item_taxes"), LineItemTaxes::fromJson); obj.lineItemCredits = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "line_item_credits")).stream() - .map(LineItemCredits::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "line_item_credits"), LineItemCredits::fromJson); obj.lineItemAddresses = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "line_item_addresses")).stream() - .map(LineItemAddresses::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "line_item_addresses"), LineItemAddresses::fromJson); obj.discounts = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "discounts")).stream() - .map(Discounts::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "discounts"), Discounts::fromJson); - obj.taxes = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "taxes")).stream() - .map(Taxes::fromJson) - .collect(java.util.stream.Collectors.toList()); + obj.taxes = JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "taxes"), Taxes::fromJson); - obj.roundOffAmount = JsonUtil.getLong(json, "round_off_amount"); + obj.roundOffAmount = JsonUtil.getLong(jsonObj, "round_off_amount"); - obj.customerId = JsonUtil.getString(json, "customer_id"); + obj.customerId = JsonUtil.getString(jsonObj, "customer_id"); return obj; } @@ -3749,58 +3796,62 @@ public static TaxExemptReason fromString(String value) { } public static LineItems fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static LineItems fromJson(JsonObject jsonObj) { LineItems obj = new LineItems(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.subscriptionId = JsonUtil.getString(json, "subscription_id"); + obj.subscriptionId = JsonUtil.getString(jsonObj, "subscription_id"); - obj.dateFrom = JsonUtil.getTimestamp(json, "date_from"); + obj.dateFrom = JsonUtil.getTimestamp(jsonObj, "date_from"); - obj.dateTo = JsonUtil.getTimestamp(json, "date_to"); + obj.dateTo = JsonUtil.getTimestamp(jsonObj, "date_to"); - obj.unitAmount = JsonUtil.getLong(json, "unit_amount"); + obj.unitAmount = JsonUtil.getLong(jsonObj, "unit_amount"); - obj.quantity = JsonUtil.getInteger(json, "quantity"); + obj.quantity = JsonUtil.getInteger(jsonObj, "quantity"); - obj.amount = JsonUtil.getLong(json, "amount"); + obj.amount = JsonUtil.getLong(jsonObj, "amount"); - obj.pricingModel = PricingModel.fromString(JsonUtil.getString(json, "pricing_model")); + obj.pricingModel = PricingModel.fromString(JsonUtil.getString(jsonObj, "pricing_model")); - obj.isTaxed = JsonUtil.getBoolean(json, "is_taxed"); + obj.isTaxed = JsonUtil.getBoolean(jsonObj, "is_taxed"); - obj.taxAmount = JsonUtil.getLong(json, "tax_amount"); + obj.taxAmount = JsonUtil.getLong(jsonObj, "tax_amount"); - obj.taxRate = JsonUtil.getDouble(json, "tax_rate"); + obj.taxRate = JsonUtil.getDouble(jsonObj, "tax_rate"); - obj.unitAmountInDecimal = JsonUtil.getString(json, "unit_amount_in_decimal"); + obj.unitAmountInDecimal = JsonUtil.getString(jsonObj, "unit_amount_in_decimal"); - obj.quantityInDecimal = JsonUtil.getString(json, "quantity_in_decimal"); + obj.quantityInDecimal = JsonUtil.getString(jsonObj, "quantity_in_decimal"); - obj.amountInDecimal = JsonUtil.getString(json, "amount_in_decimal"); + obj.amountInDecimal = JsonUtil.getString(jsonObj, "amount_in_decimal"); - obj.discountAmount = JsonUtil.getLong(json, "discount_amount"); + obj.discountAmount = JsonUtil.getLong(jsonObj, "discount_amount"); - obj.itemLevelDiscountAmount = JsonUtil.getLong(json, "item_level_discount_amount"); + obj.itemLevelDiscountAmount = JsonUtil.getLong(jsonObj, "item_level_discount_amount"); - obj.metered = JsonUtil.getBoolean(json, "metered"); + obj.metered = JsonUtil.getBoolean(jsonObj, "metered"); - obj.isPercentagePricing = JsonUtil.getBoolean(json, "is_percentage_pricing"); + obj.isPercentagePricing = JsonUtil.getBoolean(jsonObj, "is_percentage_pricing"); - obj.referenceLineItemId = JsonUtil.getString(json, "reference_line_item_id"); + obj.referenceLineItemId = JsonUtil.getString(jsonObj, "reference_line_item_id"); - obj.description = JsonUtil.getString(json, "description"); + obj.description = JsonUtil.getString(jsonObj, "description"); - obj.entityDescription = JsonUtil.getString(json, "entity_description"); + obj.entityDescription = JsonUtil.getString(jsonObj, "entity_description"); - obj.entityType = EntityType.fromString(JsonUtil.getString(json, "entity_type")); + obj.entityType = EntityType.fromString(JsonUtil.getString(jsonObj, "entity_type")); obj.taxExemptReason = - TaxExemptReason.fromString(JsonUtil.getString(json, "tax_exempt_reason")); + TaxExemptReason.fromString(JsonUtil.getString(jsonObj, "tax_exempt_reason")); - obj.entityId = JsonUtil.getString(json, "entity_id"); + obj.entityId = JsonUtil.getString(jsonObj, "entity_id"); - obj.customerId = JsonUtil.getString(json, "customer_id"); + obj.customerId = JsonUtil.getString(jsonObj, "customer_id"); return obj; } @@ -4015,29 +4066,33 @@ public static PricingType fromString(String value) { } public static LineItemTiers fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static LineItemTiers fromJson(JsonObject jsonObj) { LineItemTiers obj = new LineItemTiers(); - obj.lineItemId = JsonUtil.getString(json, "line_item_id"); + obj.lineItemId = JsonUtil.getString(jsonObj, "line_item_id"); - obj.startingUnit = JsonUtil.getInteger(json, "starting_unit"); + obj.startingUnit = JsonUtil.getInteger(jsonObj, "starting_unit"); - obj.endingUnit = JsonUtil.getInteger(json, "ending_unit"); + obj.endingUnit = JsonUtil.getInteger(jsonObj, "ending_unit"); - obj.quantityUsed = JsonUtil.getInteger(json, "quantity_used"); + obj.quantityUsed = JsonUtil.getInteger(jsonObj, "quantity_used"); - obj.unitAmount = JsonUtil.getLong(json, "unit_amount"); + obj.unitAmount = JsonUtil.getLong(jsonObj, "unit_amount"); - obj.startingUnitInDecimal = JsonUtil.getString(json, "starting_unit_in_decimal"); + obj.startingUnitInDecimal = JsonUtil.getString(jsonObj, "starting_unit_in_decimal"); - obj.endingUnitInDecimal = JsonUtil.getString(json, "ending_unit_in_decimal"); + obj.endingUnitInDecimal = JsonUtil.getString(jsonObj, "ending_unit_in_decimal"); - obj.quantityUsedInDecimal = JsonUtil.getString(json, "quantity_used_in_decimal"); + obj.quantityUsedInDecimal = JsonUtil.getString(jsonObj, "quantity_used_in_decimal"); - obj.unitAmountInDecimal = JsonUtil.getString(json, "unit_amount_in_decimal"); + obj.unitAmountInDecimal = JsonUtil.getString(jsonObj, "unit_amount_in_decimal"); - obj.pricingType = PricingType.fromString(JsonUtil.getString(json, "pricing_type")); + obj.pricingType = PricingType.fromString(JsonUtil.getString(jsonObj, "pricing_type")); - obj.packageSize = JsonUtil.getInteger(json, "package_size"); + obj.packageSize = JsonUtil.getInteger(jsonObj, "package_size"); return obj; } @@ -4172,17 +4227,21 @@ public static DiscountType fromString(String value) { } public static LineItemDiscounts fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static LineItemDiscounts fromJson(JsonObject jsonObj) { LineItemDiscounts obj = new LineItemDiscounts(); - obj.lineItemId = JsonUtil.getString(json, "line_item_id"); + obj.lineItemId = JsonUtil.getString(jsonObj, "line_item_id"); - obj.discountType = DiscountType.fromString(JsonUtil.getString(json, "discount_type")); + obj.discountType = DiscountType.fromString(JsonUtil.getString(jsonObj, "discount_type")); - obj.couponId = JsonUtil.getString(json, "coupon_id"); + obj.couponId = JsonUtil.getString(jsonObj, "coupon_id"); - obj.entityId = JsonUtil.getString(json, "entity_id"); + obj.entityId = JsonUtil.getString(jsonObj, "entity_id"); - obj.discountAmount = JsonUtil.getLong(json, "discount_amount"); + obj.discountAmount = JsonUtil.getLong(jsonObj, "discount_amount"); return obj; } @@ -4342,37 +4401,41 @@ public static TaxJurisType fromString(String value) { } public static LineItemTaxes fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static LineItemTaxes fromJson(JsonObject jsonObj) { LineItemTaxes obj = new LineItemTaxes(); - obj.lineItemId = JsonUtil.getString(json, "line_item_id"); + obj.lineItemId = JsonUtil.getString(jsonObj, "line_item_id"); - obj.taxName = JsonUtil.getString(json, "tax_name"); + obj.taxName = JsonUtil.getString(jsonObj, "tax_name"); - obj.taxRate = JsonUtil.getDouble(json, "tax_rate"); + obj.taxRate = JsonUtil.getDouble(jsonObj, "tax_rate"); - obj.dateTo = JsonUtil.getTimestamp(json, "date_to"); + obj.dateTo = JsonUtil.getTimestamp(jsonObj, "date_to"); - obj.dateFrom = JsonUtil.getTimestamp(json, "date_from"); + obj.dateFrom = JsonUtil.getTimestamp(jsonObj, "date_from"); - obj.proratedTaxableAmount = JsonUtil.getBigDecimal(json, "prorated_taxable_amount"); + obj.proratedTaxableAmount = JsonUtil.getBigDecimal(jsonObj, "prorated_taxable_amount"); - obj.isPartialTaxApplied = JsonUtil.getBoolean(json, "is_partial_tax_applied"); + obj.isPartialTaxApplied = JsonUtil.getBoolean(jsonObj, "is_partial_tax_applied"); - obj.isNonComplianceTax = JsonUtil.getBoolean(json, "is_non_compliance_tax"); + obj.isNonComplianceTax = JsonUtil.getBoolean(jsonObj, "is_non_compliance_tax"); - obj.taxableAmount = JsonUtil.getLong(json, "taxable_amount"); + obj.taxableAmount = JsonUtil.getLong(jsonObj, "taxable_amount"); - obj.taxAmount = JsonUtil.getLong(json, "tax_amount"); + obj.taxAmount = JsonUtil.getLong(jsonObj, "tax_amount"); - obj.taxJurisType = TaxJurisType.fromString(JsonUtil.getString(json, "tax_juris_type")); + obj.taxJurisType = TaxJurisType.fromString(JsonUtil.getString(jsonObj, "tax_juris_type")); - obj.taxJurisName = JsonUtil.getString(json, "tax_juris_name"); + obj.taxJurisName = JsonUtil.getString(jsonObj, "tax_juris_name"); - obj.taxJurisCode = JsonUtil.getString(json, "tax_juris_code"); + obj.taxJurisCode = JsonUtil.getString(jsonObj, "tax_juris_code"); - obj.taxAmountInLocalCurrency = JsonUtil.getLong(json, "tax_amount_in_local_currency"); + obj.taxAmountInLocalCurrency = JsonUtil.getLong(jsonObj, "tax_amount_in_local_currency"); - obj.localCurrencyCode = JsonUtil.getString(json, "local_currency_code"); + obj.localCurrencyCode = JsonUtil.getString(jsonObj, "local_currency_code"); return obj; } @@ -4477,13 +4540,17 @@ public String getLineItemId() { } public static LineItemCredits fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static LineItemCredits fromJson(JsonObject jsonObj) { LineItemCredits obj = new LineItemCredits(); - obj.cnId = JsonUtil.getString(json, "cn_id"); + obj.cnId = JsonUtil.getString(jsonObj, "cn_id"); - obj.appliedAmount = JsonUtil.getDouble(json, "applied_amount"); + obj.appliedAmount = JsonUtil.getDouble(jsonObj, "applied_amount"); - obj.lineItemId = JsonUtil.getString(json, "line_item_id"); + obj.lineItemId = JsonUtil.getString(jsonObj, "line_item_id"); return obj; } @@ -4631,38 +4698,42 @@ public static ValidationStatus fromString(String value) { } public static LineItemAddresses fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static LineItemAddresses fromJson(JsonObject jsonObj) { LineItemAddresses obj = new LineItemAddresses(); - obj.lineItemId = JsonUtil.getString(json, "line_item_id"); + obj.lineItemId = JsonUtil.getString(jsonObj, "line_item_id"); - obj.firstName = JsonUtil.getString(json, "first_name"); + obj.firstName = JsonUtil.getString(jsonObj, "first_name"); - obj.lastName = JsonUtil.getString(json, "last_name"); + obj.lastName = JsonUtil.getString(jsonObj, "last_name"); - obj.email = JsonUtil.getString(json, "email"); + obj.email = JsonUtil.getString(jsonObj, "email"); - obj.company = JsonUtil.getString(json, "company"); + obj.company = JsonUtil.getString(jsonObj, "company"); - obj.phone = JsonUtil.getString(json, "phone"); + obj.phone = JsonUtil.getString(jsonObj, "phone"); - obj.line1 = JsonUtil.getString(json, "line1"); + obj.line1 = JsonUtil.getString(jsonObj, "line1"); - obj.line2 = JsonUtil.getString(json, "line2"); + obj.line2 = JsonUtil.getString(jsonObj, "line2"); - obj.line3 = JsonUtil.getString(json, "line3"); + obj.line3 = JsonUtil.getString(jsonObj, "line3"); - obj.city = JsonUtil.getString(json, "city"); + obj.city = JsonUtil.getString(jsonObj, "city"); - obj.stateCode = JsonUtil.getString(json, "state_code"); + obj.stateCode = JsonUtil.getString(jsonObj, "state_code"); - obj.state = JsonUtil.getString(json, "state"); + obj.state = JsonUtil.getString(jsonObj, "state"); - obj.country = JsonUtil.getString(json, "country"); + obj.country = JsonUtil.getString(jsonObj, "country"); - obj.zip = JsonUtil.getString(json, "zip"); + obj.zip = JsonUtil.getString(jsonObj, "zip"); obj.validationStatus = - ValidationStatus.fromString(JsonUtil.getString(json, "validation_status")); + ValidationStatus.fromString(JsonUtil.getString(jsonObj, "validation_status")); return obj; } @@ -4851,21 +4922,25 @@ public static DiscountType fromString(String value) { } public static Discounts fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Discounts fromJson(JsonObject jsonObj) { Discounts obj = new Discounts(); - obj.amount = JsonUtil.getLong(json, "amount"); + obj.amount = JsonUtil.getLong(jsonObj, "amount"); - obj.description = JsonUtil.getString(json, "description"); + obj.description = JsonUtil.getString(jsonObj, "description"); - obj.lineItemId = JsonUtil.getString(json, "line_item_id"); + obj.lineItemId = JsonUtil.getString(jsonObj, "line_item_id"); - obj.entityType = EntityType.fromString(JsonUtil.getString(json, "entity_type")); + obj.entityType = EntityType.fromString(JsonUtil.getString(jsonObj, "entity_type")); - obj.discountType = DiscountType.fromString(JsonUtil.getString(json, "discount_type")); + obj.discountType = DiscountType.fromString(JsonUtil.getString(jsonObj, "discount_type")); - obj.entityId = JsonUtil.getString(json, "entity_id"); + obj.entityId = JsonUtil.getString(jsonObj, "entity_id"); - obj.couponSetCode = JsonUtil.getString(json, "coupon_set_code"); + obj.couponSetCode = JsonUtil.getString(jsonObj, "coupon_set_code"); return obj; } @@ -4932,13 +5007,17 @@ public String getDescription() { } public static Taxes fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Taxes fromJson(JsonObject jsonObj) { Taxes obj = new Taxes(); - obj.name = JsonUtil.getString(json, "name"); + obj.name = JsonUtil.getString(jsonObj, "name"); - obj.amount = JsonUtil.getLong(json, "amount"); + obj.amount = JsonUtil.getLong(jsonObj, "amount"); - obj.description = JsonUtil.getString(json, "description"); + obj.description = JsonUtil.getString(jsonObj, "description"); return obj; } @@ -5039,24 +5118,27 @@ public static EntityType fromString(String value) { } public static PaymentScheduleEstimates fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static PaymentScheduleEstimates fromJson(JsonObject jsonObj) { PaymentScheduleEstimates obj = new PaymentScheduleEstimates(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.schemeId = JsonUtil.getString(json, "scheme_id"); + obj.schemeId = JsonUtil.getString(jsonObj, "scheme_id"); - obj.entityType = EntityType.fromString(JsonUtil.getString(json, "entity_type")); + obj.entityType = EntityType.fromString(JsonUtil.getString(jsonObj, "entity_type")); - obj.entityId = JsonUtil.getString(json, "entity_id"); + obj.entityId = JsonUtil.getString(jsonObj, "entity_id"); - obj.amount = JsonUtil.getLong(json, "amount"); + obj.amount = JsonUtil.getLong(jsonObj, "amount"); - obj.currencyCode = JsonUtil.getString(json, "currency_code"); + obj.currencyCode = JsonUtil.getString(jsonObj, "currency_code"); obj.scheduleEntries = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "schedule_entries")).stream() - .map(ScheduleEntries::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "schedule_entries"), ScheduleEntries::fromJson); return obj; } @@ -5157,15 +5239,19 @@ public static Status fromString(String value) { } public static ScheduleEntries fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static ScheduleEntries fromJson(JsonObject jsonObj) { ScheduleEntries obj = new ScheduleEntries(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.date = JsonUtil.getTimestamp(json, "date"); + obj.date = JsonUtil.getTimestamp(jsonObj, "date"); - obj.amount = JsonUtil.getLong(json, "amount"); + obj.amount = JsonUtil.getLong(jsonObj, "amount"); - obj.status = Status.fromString(JsonUtil.getString(json, "status")); + obj.status = Status.fromString(JsonUtil.getString(jsonObj, "status")); return obj; } @@ -5326,67 +5412,59 @@ public static PriceType fromString(String value) { } public static NextInvoiceEstimate fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static NextInvoiceEstimate fromJson(JsonObject jsonObj) { NextInvoiceEstimate obj = new NextInvoiceEstimate(); - obj.recurring = JsonUtil.getBoolean(json, "recurring"); + obj.recurring = JsonUtil.getBoolean(jsonObj, "recurring"); - obj.priceType = PriceType.fromString(JsonUtil.getString(json, "price_type")); + obj.priceType = PriceType.fromString(JsonUtil.getString(jsonObj, "price_type")); - obj.currencyCode = JsonUtil.getString(json, "currency_code"); + obj.currencyCode = JsonUtil.getString(jsonObj, "currency_code"); - obj.subTotal = JsonUtil.getLong(json, "sub_total"); + obj.subTotal = JsonUtil.getLong(jsonObj, "sub_total"); - obj.total = JsonUtil.getLong(json, "total"); + obj.total = JsonUtil.getLong(jsonObj, "total"); - obj.creditsApplied = JsonUtil.getLong(json, "credits_applied"); + obj.creditsApplied = JsonUtil.getLong(jsonObj, "credits_applied"); - obj.amountPaid = JsonUtil.getLong(json, "amount_paid"); + obj.amountPaid = JsonUtil.getLong(jsonObj, "amount_paid"); - obj.amountDue = JsonUtil.getLong(json, "amount_due"); + obj.amountDue = JsonUtil.getLong(jsonObj, "amount_due"); obj.lineItems = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "line_items")).stream() - .map(LineItems::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "line_items"), LineItems::fromJson); obj.lineItemTiers = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "line_item_tiers")).stream() - .map(LineItemTiers::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "line_item_tiers"), LineItemTiers::fromJson); obj.lineItemDiscounts = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "line_item_discounts")).stream() - .map(LineItemDiscounts::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "line_item_discounts"), LineItemDiscounts::fromJson); obj.lineItemTaxes = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "line_item_taxes")).stream() - .map(LineItemTaxes::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "line_item_taxes"), LineItemTaxes::fromJson); obj.lineItemCredits = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "line_item_credits")).stream() - .map(LineItemCredits::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "line_item_credits"), LineItemCredits::fromJson); obj.lineItemAddresses = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "line_item_addresses")).stream() - .map(LineItemAddresses::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "line_item_addresses"), LineItemAddresses::fromJson); obj.discounts = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "discounts")).stream() - .map(Discounts::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "discounts"), Discounts::fromJson); - obj.taxes = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "taxes")).stream() - .map(Taxes::fromJson) - .collect(java.util.stream.Collectors.toList()); + obj.taxes = JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "taxes"), Taxes::fromJson); - obj.roundOffAmount = JsonUtil.getLong(json, "round_off_amount"); + obj.roundOffAmount = JsonUtil.getLong(jsonObj, "round_off_amount"); - obj.customerId = JsonUtil.getString(json, "customer_id"); + obj.customerId = JsonUtil.getString(jsonObj, "customer_id"); return obj; } @@ -5730,58 +5808,62 @@ public static TaxExemptReason fromString(String value) { } public static LineItems fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static LineItems fromJson(JsonObject jsonObj) { LineItems obj = new LineItems(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.subscriptionId = JsonUtil.getString(json, "subscription_id"); + obj.subscriptionId = JsonUtil.getString(jsonObj, "subscription_id"); - obj.dateFrom = JsonUtil.getTimestamp(json, "date_from"); + obj.dateFrom = JsonUtil.getTimestamp(jsonObj, "date_from"); - obj.dateTo = JsonUtil.getTimestamp(json, "date_to"); + obj.dateTo = JsonUtil.getTimestamp(jsonObj, "date_to"); - obj.unitAmount = JsonUtil.getLong(json, "unit_amount"); + obj.unitAmount = JsonUtil.getLong(jsonObj, "unit_amount"); - obj.quantity = JsonUtil.getInteger(json, "quantity"); + obj.quantity = JsonUtil.getInteger(jsonObj, "quantity"); - obj.amount = JsonUtil.getLong(json, "amount"); + obj.amount = JsonUtil.getLong(jsonObj, "amount"); - obj.pricingModel = PricingModel.fromString(JsonUtil.getString(json, "pricing_model")); + obj.pricingModel = PricingModel.fromString(JsonUtil.getString(jsonObj, "pricing_model")); - obj.isTaxed = JsonUtil.getBoolean(json, "is_taxed"); + obj.isTaxed = JsonUtil.getBoolean(jsonObj, "is_taxed"); - obj.taxAmount = JsonUtil.getLong(json, "tax_amount"); + obj.taxAmount = JsonUtil.getLong(jsonObj, "tax_amount"); - obj.taxRate = JsonUtil.getDouble(json, "tax_rate"); + obj.taxRate = JsonUtil.getDouble(jsonObj, "tax_rate"); - obj.unitAmountInDecimal = JsonUtil.getString(json, "unit_amount_in_decimal"); + obj.unitAmountInDecimal = JsonUtil.getString(jsonObj, "unit_amount_in_decimal"); - obj.quantityInDecimal = JsonUtil.getString(json, "quantity_in_decimal"); + obj.quantityInDecimal = JsonUtil.getString(jsonObj, "quantity_in_decimal"); - obj.amountInDecimal = JsonUtil.getString(json, "amount_in_decimal"); + obj.amountInDecimal = JsonUtil.getString(jsonObj, "amount_in_decimal"); - obj.discountAmount = JsonUtil.getLong(json, "discount_amount"); + obj.discountAmount = JsonUtil.getLong(jsonObj, "discount_amount"); - obj.itemLevelDiscountAmount = JsonUtil.getLong(json, "item_level_discount_amount"); + obj.itemLevelDiscountAmount = JsonUtil.getLong(jsonObj, "item_level_discount_amount"); - obj.metered = JsonUtil.getBoolean(json, "metered"); + obj.metered = JsonUtil.getBoolean(jsonObj, "metered"); - obj.isPercentagePricing = JsonUtil.getBoolean(json, "is_percentage_pricing"); + obj.isPercentagePricing = JsonUtil.getBoolean(jsonObj, "is_percentage_pricing"); - obj.referenceLineItemId = JsonUtil.getString(json, "reference_line_item_id"); + obj.referenceLineItemId = JsonUtil.getString(jsonObj, "reference_line_item_id"); - obj.description = JsonUtil.getString(json, "description"); + obj.description = JsonUtil.getString(jsonObj, "description"); - obj.entityDescription = JsonUtil.getString(json, "entity_description"); + obj.entityDescription = JsonUtil.getString(jsonObj, "entity_description"); - obj.entityType = EntityType.fromString(JsonUtil.getString(json, "entity_type")); + obj.entityType = EntityType.fromString(JsonUtil.getString(jsonObj, "entity_type")); obj.taxExemptReason = - TaxExemptReason.fromString(JsonUtil.getString(json, "tax_exempt_reason")); + TaxExemptReason.fromString(JsonUtil.getString(jsonObj, "tax_exempt_reason")); - obj.entityId = JsonUtil.getString(json, "entity_id"); + obj.entityId = JsonUtil.getString(jsonObj, "entity_id"); - obj.customerId = JsonUtil.getString(json, "customer_id"); + obj.customerId = JsonUtil.getString(jsonObj, "customer_id"); return obj; } @@ -5996,29 +6078,33 @@ public static PricingType fromString(String value) { } public static LineItemTiers fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static LineItemTiers fromJson(JsonObject jsonObj) { LineItemTiers obj = new LineItemTiers(); - obj.lineItemId = JsonUtil.getString(json, "line_item_id"); + obj.lineItemId = JsonUtil.getString(jsonObj, "line_item_id"); - obj.startingUnit = JsonUtil.getInteger(json, "starting_unit"); + obj.startingUnit = JsonUtil.getInteger(jsonObj, "starting_unit"); - obj.endingUnit = JsonUtil.getInteger(json, "ending_unit"); + obj.endingUnit = JsonUtil.getInteger(jsonObj, "ending_unit"); - obj.quantityUsed = JsonUtil.getInteger(json, "quantity_used"); + obj.quantityUsed = JsonUtil.getInteger(jsonObj, "quantity_used"); - obj.unitAmount = JsonUtil.getLong(json, "unit_amount"); + obj.unitAmount = JsonUtil.getLong(jsonObj, "unit_amount"); - obj.startingUnitInDecimal = JsonUtil.getString(json, "starting_unit_in_decimal"); + obj.startingUnitInDecimal = JsonUtil.getString(jsonObj, "starting_unit_in_decimal"); - obj.endingUnitInDecimal = JsonUtil.getString(json, "ending_unit_in_decimal"); + obj.endingUnitInDecimal = JsonUtil.getString(jsonObj, "ending_unit_in_decimal"); - obj.quantityUsedInDecimal = JsonUtil.getString(json, "quantity_used_in_decimal"); + obj.quantityUsedInDecimal = JsonUtil.getString(jsonObj, "quantity_used_in_decimal"); - obj.unitAmountInDecimal = JsonUtil.getString(json, "unit_amount_in_decimal"); + obj.unitAmountInDecimal = JsonUtil.getString(jsonObj, "unit_amount_in_decimal"); - obj.pricingType = PricingType.fromString(JsonUtil.getString(json, "pricing_type")); + obj.pricingType = PricingType.fromString(JsonUtil.getString(jsonObj, "pricing_type")); - obj.packageSize = JsonUtil.getInteger(json, "package_size"); + obj.packageSize = JsonUtil.getInteger(jsonObj, "package_size"); return obj; } @@ -6153,17 +6239,21 @@ public static DiscountType fromString(String value) { } public static LineItemDiscounts fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static LineItemDiscounts fromJson(JsonObject jsonObj) { LineItemDiscounts obj = new LineItemDiscounts(); - obj.lineItemId = JsonUtil.getString(json, "line_item_id"); + obj.lineItemId = JsonUtil.getString(jsonObj, "line_item_id"); - obj.discountType = DiscountType.fromString(JsonUtil.getString(json, "discount_type")); + obj.discountType = DiscountType.fromString(JsonUtil.getString(jsonObj, "discount_type")); - obj.couponId = JsonUtil.getString(json, "coupon_id"); + obj.couponId = JsonUtil.getString(jsonObj, "coupon_id"); - obj.entityId = JsonUtil.getString(json, "entity_id"); + obj.entityId = JsonUtil.getString(jsonObj, "entity_id"); - obj.discountAmount = JsonUtil.getLong(json, "discount_amount"); + obj.discountAmount = JsonUtil.getLong(jsonObj, "discount_amount"); return obj; } @@ -6323,37 +6413,41 @@ public static TaxJurisType fromString(String value) { } public static LineItemTaxes fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static LineItemTaxes fromJson(JsonObject jsonObj) { LineItemTaxes obj = new LineItemTaxes(); - obj.lineItemId = JsonUtil.getString(json, "line_item_id"); + obj.lineItemId = JsonUtil.getString(jsonObj, "line_item_id"); - obj.taxName = JsonUtil.getString(json, "tax_name"); + obj.taxName = JsonUtil.getString(jsonObj, "tax_name"); - obj.taxRate = JsonUtil.getDouble(json, "tax_rate"); + obj.taxRate = JsonUtil.getDouble(jsonObj, "tax_rate"); - obj.dateTo = JsonUtil.getTimestamp(json, "date_to"); + obj.dateTo = JsonUtil.getTimestamp(jsonObj, "date_to"); - obj.dateFrom = JsonUtil.getTimestamp(json, "date_from"); + obj.dateFrom = JsonUtil.getTimestamp(jsonObj, "date_from"); - obj.proratedTaxableAmount = JsonUtil.getBigDecimal(json, "prorated_taxable_amount"); + obj.proratedTaxableAmount = JsonUtil.getBigDecimal(jsonObj, "prorated_taxable_amount"); - obj.isPartialTaxApplied = JsonUtil.getBoolean(json, "is_partial_tax_applied"); + obj.isPartialTaxApplied = JsonUtil.getBoolean(jsonObj, "is_partial_tax_applied"); - obj.isNonComplianceTax = JsonUtil.getBoolean(json, "is_non_compliance_tax"); + obj.isNonComplianceTax = JsonUtil.getBoolean(jsonObj, "is_non_compliance_tax"); - obj.taxableAmount = JsonUtil.getLong(json, "taxable_amount"); + obj.taxableAmount = JsonUtil.getLong(jsonObj, "taxable_amount"); - obj.taxAmount = JsonUtil.getLong(json, "tax_amount"); + obj.taxAmount = JsonUtil.getLong(jsonObj, "tax_amount"); - obj.taxJurisType = TaxJurisType.fromString(JsonUtil.getString(json, "tax_juris_type")); + obj.taxJurisType = TaxJurisType.fromString(JsonUtil.getString(jsonObj, "tax_juris_type")); - obj.taxJurisName = JsonUtil.getString(json, "tax_juris_name"); + obj.taxJurisName = JsonUtil.getString(jsonObj, "tax_juris_name"); - obj.taxJurisCode = JsonUtil.getString(json, "tax_juris_code"); + obj.taxJurisCode = JsonUtil.getString(jsonObj, "tax_juris_code"); - obj.taxAmountInLocalCurrency = JsonUtil.getLong(json, "tax_amount_in_local_currency"); + obj.taxAmountInLocalCurrency = JsonUtil.getLong(jsonObj, "tax_amount_in_local_currency"); - obj.localCurrencyCode = JsonUtil.getString(json, "local_currency_code"); + obj.localCurrencyCode = JsonUtil.getString(jsonObj, "local_currency_code"); return obj; } @@ -6458,13 +6552,17 @@ public String getLineItemId() { } public static LineItemCredits fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static LineItemCredits fromJson(JsonObject jsonObj) { LineItemCredits obj = new LineItemCredits(); - obj.cnId = JsonUtil.getString(json, "cn_id"); + obj.cnId = JsonUtil.getString(jsonObj, "cn_id"); - obj.appliedAmount = JsonUtil.getDouble(json, "applied_amount"); + obj.appliedAmount = JsonUtil.getDouble(jsonObj, "applied_amount"); - obj.lineItemId = JsonUtil.getString(json, "line_item_id"); + obj.lineItemId = JsonUtil.getString(jsonObj, "line_item_id"); return obj; } @@ -6612,38 +6710,42 @@ public static ValidationStatus fromString(String value) { } public static LineItemAddresses fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static LineItemAddresses fromJson(JsonObject jsonObj) { LineItemAddresses obj = new LineItemAddresses(); - obj.lineItemId = JsonUtil.getString(json, "line_item_id"); + obj.lineItemId = JsonUtil.getString(jsonObj, "line_item_id"); - obj.firstName = JsonUtil.getString(json, "first_name"); + obj.firstName = JsonUtil.getString(jsonObj, "first_name"); - obj.lastName = JsonUtil.getString(json, "last_name"); + obj.lastName = JsonUtil.getString(jsonObj, "last_name"); - obj.email = JsonUtil.getString(json, "email"); + obj.email = JsonUtil.getString(jsonObj, "email"); - obj.company = JsonUtil.getString(json, "company"); + obj.company = JsonUtil.getString(jsonObj, "company"); - obj.phone = JsonUtil.getString(json, "phone"); + obj.phone = JsonUtil.getString(jsonObj, "phone"); - obj.line1 = JsonUtil.getString(json, "line1"); + obj.line1 = JsonUtil.getString(jsonObj, "line1"); - obj.line2 = JsonUtil.getString(json, "line2"); + obj.line2 = JsonUtil.getString(jsonObj, "line2"); - obj.line3 = JsonUtil.getString(json, "line3"); + obj.line3 = JsonUtil.getString(jsonObj, "line3"); - obj.city = JsonUtil.getString(json, "city"); + obj.city = JsonUtil.getString(jsonObj, "city"); - obj.stateCode = JsonUtil.getString(json, "state_code"); + obj.stateCode = JsonUtil.getString(jsonObj, "state_code"); - obj.state = JsonUtil.getString(json, "state"); + obj.state = JsonUtil.getString(jsonObj, "state"); - obj.country = JsonUtil.getString(json, "country"); + obj.country = JsonUtil.getString(jsonObj, "country"); - obj.zip = JsonUtil.getString(json, "zip"); + obj.zip = JsonUtil.getString(jsonObj, "zip"); obj.validationStatus = - ValidationStatus.fromString(JsonUtil.getString(json, "validation_status")); + ValidationStatus.fromString(JsonUtil.getString(jsonObj, "validation_status")); return obj; } @@ -6832,21 +6934,25 @@ public static DiscountType fromString(String value) { } public static Discounts fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Discounts fromJson(JsonObject jsonObj) { Discounts obj = new Discounts(); - obj.amount = JsonUtil.getLong(json, "amount"); + obj.amount = JsonUtil.getLong(jsonObj, "amount"); - obj.description = JsonUtil.getString(json, "description"); + obj.description = JsonUtil.getString(jsonObj, "description"); - obj.lineItemId = JsonUtil.getString(json, "line_item_id"); + obj.lineItemId = JsonUtil.getString(jsonObj, "line_item_id"); - obj.entityType = EntityType.fromString(JsonUtil.getString(json, "entity_type")); + obj.entityType = EntityType.fromString(JsonUtil.getString(jsonObj, "entity_type")); - obj.discountType = DiscountType.fromString(JsonUtil.getString(json, "discount_type")); + obj.discountType = DiscountType.fromString(JsonUtil.getString(jsonObj, "discount_type")); - obj.entityId = JsonUtil.getString(json, "entity_id"); + obj.entityId = JsonUtil.getString(jsonObj, "entity_id"); - obj.couponSetCode = JsonUtil.getString(json, "coupon_set_code"); + obj.couponSetCode = JsonUtil.getString(jsonObj, "coupon_set_code"); return obj; } @@ -6913,13 +7019,17 @@ public String getDescription() { } public static Taxes fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Taxes fromJson(JsonObject jsonObj) { Taxes obj = new Taxes(); - obj.name = JsonUtil.getString(json, "name"); + obj.name = JsonUtil.getString(jsonObj, "name"); - obj.amount = JsonUtil.getLong(json, "amount"); + obj.amount = JsonUtil.getLong(jsonObj, "amount"); - obj.description = JsonUtil.getString(json, "description"); + obj.description = JsonUtil.getString(jsonObj, "description"); return obj; } @@ -7097,57 +7207,51 @@ public static PriceType fromString(String value) { } public static CreditNoteEstimates fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static CreditNoteEstimates fromJson(JsonObject jsonObj) { CreditNoteEstimates obj = new CreditNoteEstimates(); - obj.referenceInvoiceId = JsonUtil.getString(json, "reference_invoice_id"); + obj.referenceInvoiceId = JsonUtil.getString(jsonObj, "reference_invoice_id"); - obj.type = Type.fromString(JsonUtil.getString(json, "type")); + obj.type = Type.fromString(JsonUtil.getString(jsonObj, "type")); - obj.priceType = PriceType.fromString(JsonUtil.getString(json, "price_type")); + obj.priceType = PriceType.fromString(JsonUtil.getString(jsonObj, "price_type")); - obj.currencyCode = JsonUtil.getString(json, "currency_code"); + obj.currencyCode = JsonUtil.getString(jsonObj, "currency_code"); - obj.subTotal = JsonUtil.getLong(json, "sub_total"); + obj.subTotal = JsonUtil.getLong(jsonObj, "sub_total"); - obj.total = JsonUtil.getLong(json, "total"); + obj.total = JsonUtil.getLong(jsonObj, "total"); - obj.amountAllocated = JsonUtil.getLong(json, "amount_allocated"); + obj.amountAllocated = JsonUtil.getLong(jsonObj, "amount_allocated"); - obj.amountAvailable = JsonUtil.getLong(json, "amount_available"); + obj.amountAvailable = JsonUtil.getLong(jsonObj, "amount_available"); obj.lineItems = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "line_items")).stream() - .map(LineItems::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "line_items"), LineItems::fromJson); obj.lineItemTiers = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "line_item_tiers")).stream() - .map(LineItemTiers::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "line_item_tiers"), LineItemTiers::fromJson); obj.lineItemDiscounts = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "line_item_discounts")).stream() - .map(LineItemDiscounts::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "line_item_discounts"), LineItemDiscounts::fromJson); obj.lineItemTaxes = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "line_item_taxes")).stream() - .map(LineItemTaxes::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "line_item_taxes"), LineItemTaxes::fromJson); obj.discounts = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "discounts")).stream() - .map(Discounts::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "discounts"), Discounts::fromJson); - obj.taxes = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "taxes")).stream() - .map(Taxes::fromJson) - .collect(java.util.stream.Collectors.toList()); + obj.taxes = JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "taxes"), Taxes::fromJson); - obj.roundOffAmount = JsonUtil.getLong(json, "round_off_amount"); + obj.roundOffAmount = JsonUtil.getLong(jsonObj, "round_off_amount"); - obj.customerId = JsonUtil.getString(json, "customer_id"); + obj.customerId = JsonUtil.getString(jsonObj, "customer_id"); return obj; } @@ -7483,58 +7587,62 @@ public static TaxExemptReason fromString(String value) { } public static LineItems fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static LineItems fromJson(JsonObject jsonObj) { LineItems obj = new LineItems(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.subscriptionId = JsonUtil.getString(json, "subscription_id"); + obj.subscriptionId = JsonUtil.getString(jsonObj, "subscription_id"); - obj.dateFrom = JsonUtil.getTimestamp(json, "date_from"); + obj.dateFrom = JsonUtil.getTimestamp(jsonObj, "date_from"); - obj.dateTo = JsonUtil.getTimestamp(json, "date_to"); + obj.dateTo = JsonUtil.getTimestamp(jsonObj, "date_to"); - obj.unitAmount = JsonUtil.getLong(json, "unit_amount"); + obj.unitAmount = JsonUtil.getLong(jsonObj, "unit_amount"); - obj.quantity = JsonUtil.getInteger(json, "quantity"); + obj.quantity = JsonUtil.getInteger(jsonObj, "quantity"); - obj.amount = JsonUtil.getLong(json, "amount"); + obj.amount = JsonUtil.getLong(jsonObj, "amount"); - obj.pricingModel = PricingModel.fromString(JsonUtil.getString(json, "pricing_model")); + obj.pricingModel = PricingModel.fromString(JsonUtil.getString(jsonObj, "pricing_model")); - obj.isTaxed = JsonUtil.getBoolean(json, "is_taxed"); + obj.isTaxed = JsonUtil.getBoolean(jsonObj, "is_taxed"); - obj.taxAmount = JsonUtil.getLong(json, "tax_amount"); + obj.taxAmount = JsonUtil.getLong(jsonObj, "tax_amount"); - obj.taxRate = JsonUtil.getDouble(json, "tax_rate"); + obj.taxRate = JsonUtil.getDouble(jsonObj, "tax_rate"); - obj.unitAmountInDecimal = JsonUtil.getString(json, "unit_amount_in_decimal"); + obj.unitAmountInDecimal = JsonUtil.getString(jsonObj, "unit_amount_in_decimal"); - obj.quantityInDecimal = JsonUtil.getString(json, "quantity_in_decimal"); + obj.quantityInDecimal = JsonUtil.getString(jsonObj, "quantity_in_decimal"); - obj.amountInDecimal = JsonUtil.getString(json, "amount_in_decimal"); + obj.amountInDecimal = JsonUtil.getString(jsonObj, "amount_in_decimal"); - obj.discountAmount = JsonUtil.getLong(json, "discount_amount"); + obj.discountAmount = JsonUtil.getLong(jsonObj, "discount_amount"); - obj.itemLevelDiscountAmount = JsonUtil.getLong(json, "item_level_discount_amount"); + obj.itemLevelDiscountAmount = JsonUtil.getLong(jsonObj, "item_level_discount_amount"); - obj.metered = JsonUtil.getBoolean(json, "metered"); + obj.metered = JsonUtil.getBoolean(jsonObj, "metered"); - obj.isPercentagePricing = JsonUtil.getBoolean(json, "is_percentage_pricing"); + obj.isPercentagePricing = JsonUtil.getBoolean(jsonObj, "is_percentage_pricing"); - obj.referenceLineItemId = JsonUtil.getString(json, "reference_line_item_id"); + obj.referenceLineItemId = JsonUtil.getString(jsonObj, "reference_line_item_id"); - obj.description = JsonUtil.getString(json, "description"); + obj.description = JsonUtil.getString(jsonObj, "description"); - obj.entityDescription = JsonUtil.getString(json, "entity_description"); + obj.entityDescription = JsonUtil.getString(jsonObj, "entity_description"); - obj.entityType = EntityType.fromString(JsonUtil.getString(json, "entity_type")); + obj.entityType = EntityType.fromString(JsonUtil.getString(jsonObj, "entity_type")); obj.taxExemptReason = - TaxExemptReason.fromString(JsonUtil.getString(json, "tax_exempt_reason")); + TaxExemptReason.fromString(JsonUtil.getString(jsonObj, "tax_exempt_reason")); - obj.entityId = JsonUtil.getString(json, "entity_id"); + obj.entityId = JsonUtil.getString(jsonObj, "entity_id"); - obj.customerId = JsonUtil.getString(json, "customer_id"); + obj.customerId = JsonUtil.getString(jsonObj, "customer_id"); return obj; } @@ -7749,29 +7857,33 @@ public static PricingType fromString(String value) { } public static LineItemTiers fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static LineItemTiers fromJson(JsonObject jsonObj) { LineItemTiers obj = new LineItemTiers(); - obj.lineItemId = JsonUtil.getString(json, "line_item_id"); + obj.lineItemId = JsonUtil.getString(jsonObj, "line_item_id"); - obj.startingUnit = JsonUtil.getInteger(json, "starting_unit"); + obj.startingUnit = JsonUtil.getInteger(jsonObj, "starting_unit"); - obj.endingUnit = JsonUtil.getInteger(json, "ending_unit"); + obj.endingUnit = JsonUtil.getInteger(jsonObj, "ending_unit"); - obj.quantityUsed = JsonUtil.getInteger(json, "quantity_used"); + obj.quantityUsed = JsonUtil.getInteger(jsonObj, "quantity_used"); - obj.unitAmount = JsonUtil.getLong(json, "unit_amount"); + obj.unitAmount = JsonUtil.getLong(jsonObj, "unit_amount"); - obj.startingUnitInDecimal = JsonUtil.getString(json, "starting_unit_in_decimal"); + obj.startingUnitInDecimal = JsonUtil.getString(jsonObj, "starting_unit_in_decimal"); - obj.endingUnitInDecimal = JsonUtil.getString(json, "ending_unit_in_decimal"); + obj.endingUnitInDecimal = JsonUtil.getString(jsonObj, "ending_unit_in_decimal"); - obj.quantityUsedInDecimal = JsonUtil.getString(json, "quantity_used_in_decimal"); + obj.quantityUsedInDecimal = JsonUtil.getString(jsonObj, "quantity_used_in_decimal"); - obj.unitAmountInDecimal = JsonUtil.getString(json, "unit_amount_in_decimal"); + obj.unitAmountInDecimal = JsonUtil.getString(jsonObj, "unit_amount_in_decimal"); - obj.pricingType = PricingType.fromString(JsonUtil.getString(json, "pricing_type")); + obj.pricingType = PricingType.fromString(JsonUtil.getString(jsonObj, "pricing_type")); - obj.packageSize = JsonUtil.getInteger(json, "package_size"); + obj.packageSize = JsonUtil.getInteger(jsonObj, "package_size"); return obj; } @@ -7906,17 +8018,21 @@ public static DiscountType fromString(String value) { } public static LineItemDiscounts fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static LineItemDiscounts fromJson(JsonObject jsonObj) { LineItemDiscounts obj = new LineItemDiscounts(); - obj.lineItemId = JsonUtil.getString(json, "line_item_id"); + obj.lineItemId = JsonUtil.getString(jsonObj, "line_item_id"); - obj.discountType = DiscountType.fromString(JsonUtil.getString(json, "discount_type")); + obj.discountType = DiscountType.fromString(JsonUtil.getString(jsonObj, "discount_type")); - obj.couponId = JsonUtil.getString(json, "coupon_id"); + obj.couponId = JsonUtil.getString(jsonObj, "coupon_id"); - obj.entityId = JsonUtil.getString(json, "entity_id"); + obj.entityId = JsonUtil.getString(jsonObj, "entity_id"); - obj.discountAmount = JsonUtil.getLong(json, "discount_amount"); + obj.discountAmount = JsonUtil.getLong(jsonObj, "discount_amount"); return obj; } @@ -8076,37 +8192,41 @@ public static TaxJurisType fromString(String value) { } public static LineItemTaxes fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static LineItemTaxes fromJson(JsonObject jsonObj) { LineItemTaxes obj = new LineItemTaxes(); - obj.lineItemId = JsonUtil.getString(json, "line_item_id"); + obj.lineItemId = JsonUtil.getString(jsonObj, "line_item_id"); - obj.taxName = JsonUtil.getString(json, "tax_name"); + obj.taxName = JsonUtil.getString(jsonObj, "tax_name"); - obj.taxRate = JsonUtil.getDouble(json, "tax_rate"); + obj.taxRate = JsonUtil.getDouble(jsonObj, "tax_rate"); - obj.dateTo = JsonUtil.getTimestamp(json, "date_to"); + obj.dateTo = JsonUtil.getTimestamp(jsonObj, "date_to"); - obj.dateFrom = JsonUtil.getTimestamp(json, "date_from"); + obj.dateFrom = JsonUtil.getTimestamp(jsonObj, "date_from"); - obj.proratedTaxableAmount = JsonUtil.getBigDecimal(json, "prorated_taxable_amount"); + obj.proratedTaxableAmount = JsonUtil.getBigDecimal(jsonObj, "prorated_taxable_amount"); - obj.isPartialTaxApplied = JsonUtil.getBoolean(json, "is_partial_tax_applied"); + obj.isPartialTaxApplied = JsonUtil.getBoolean(jsonObj, "is_partial_tax_applied"); - obj.isNonComplianceTax = JsonUtil.getBoolean(json, "is_non_compliance_tax"); + obj.isNonComplianceTax = JsonUtil.getBoolean(jsonObj, "is_non_compliance_tax"); - obj.taxableAmount = JsonUtil.getLong(json, "taxable_amount"); + obj.taxableAmount = JsonUtil.getLong(jsonObj, "taxable_amount"); - obj.taxAmount = JsonUtil.getLong(json, "tax_amount"); + obj.taxAmount = JsonUtil.getLong(jsonObj, "tax_amount"); - obj.taxJurisType = TaxJurisType.fromString(JsonUtil.getString(json, "tax_juris_type")); + obj.taxJurisType = TaxJurisType.fromString(JsonUtil.getString(jsonObj, "tax_juris_type")); - obj.taxJurisName = JsonUtil.getString(json, "tax_juris_name"); + obj.taxJurisName = JsonUtil.getString(jsonObj, "tax_juris_name"); - obj.taxJurisCode = JsonUtil.getString(json, "tax_juris_code"); + obj.taxJurisCode = JsonUtil.getString(jsonObj, "tax_juris_code"); - obj.taxAmountInLocalCurrency = JsonUtil.getLong(json, "tax_amount_in_local_currency"); + obj.taxAmountInLocalCurrency = JsonUtil.getLong(jsonObj, "tax_amount_in_local_currency"); - obj.localCurrencyCode = JsonUtil.getString(json, "local_currency_code"); + obj.localCurrencyCode = JsonUtil.getString(jsonObj, "local_currency_code"); return obj; } @@ -8295,21 +8415,25 @@ public static DiscountType fromString(String value) { } public static Discounts fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Discounts fromJson(JsonObject jsonObj) { Discounts obj = new Discounts(); - obj.amount = JsonUtil.getLong(json, "amount"); + obj.amount = JsonUtil.getLong(jsonObj, "amount"); - obj.description = JsonUtil.getString(json, "description"); + obj.description = JsonUtil.getString(jsonObj, "description"); - obj.lineItemId = JsonUtil.getString(json, "line_item_id"); + obj.lineItemId = JsonUtil.getString(jsonObj, "line_item_id"); - obj.entityType = EntityType.fromString(JsonUtil.getString(json, "entity_type")); + obj.entityType = EntityType.fromString(JsonUtil.getString(jsonObj, "entity_type")); - obj.discountType = DiscountType.fromString(JsonUtil.getString(json, "discount_type")); + obj.discountType = DiscountType.fromString(JsonUtil.getString(jsonObj, "discount_type")); - obj.entityId = JsonUtil.getString(json, "entity_id"); + obj.entityId = JsonUtil.getString(jsonObj, "entity_id"); - obj.couponSetCode = JsonUtil.getString(json, "coupon_set_code"); + obj.couponSetCode = JsonUtil.getString(jsonObj, "coupon_set_code"); return obj; } @@ -8376,13 +8500,17 @@ public String getDescription() { } public static Taxes fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Taxes fromJson(JsonObject jsonObj) { Taxes obj = new Taxes(); - obj.name = JsonUtil.getString(json, "name"); + obj.name = JsonUtil.getString(jsonObj, "name"); - obj.amount = JsonUtil.getLong(json, "amount"); + obj.amount = JsonUtil.getLong(jsonObj, "amount"); - obj.description = JsonUtil.getString(json, "description"); + obj.description = JsonUtil.getString(jsonObj, "description"); return obj; } @@ -8614,58 +8742,59 @@ public static EntityType fromString(String value) { } public static UnbilledChargeEstimates fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static UnbilledChargeEstimates fromJson(JsonObject jsonObj) { UnbilledChargeEstimates obj = new UnbilledChargeEstimates(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.customerId = JsonUtil.getString(json, "customer_id"); + obj.customerId = JsonUtil.getString(jsonObj, "customer_id"); - obj.subscriptionId = JsonUtil.getString(json, "subscription_id"); + obj.subscriptionId = JsonUtil.getString(jsonObj, "subscription_id"); - obj.dateFrom = JsonUtil.getTimestamp(json, "date_from"); + obj.dateFrom = JsonUtil.getTimestamp(jsonObj, "date_from"); - obj.dateTo = JsonUtil.getTimestamp(json, "date_to"); + obj.dateTo = JsonUtil.getTimestamp(jsonObj, "date_to"); - obj.unitAmount = JsonUtil.getLong(json, "unit_amount"); + obj.unitAmount = JsonUtil.getLong(jsonObj, "unit_amount"); - obj.pricingModel = PricingModel.fromString(JsonUtil.getString(json, "pricing_model")); + obj.pricingModel = PricingModel.fromString(JsonUtil.getString(jsonObj, "pricing_model")); - obj.quantity = JsonUtil.getInteger(json, "quantity"); + obj.quantity = JsonUtil.getInteger(jsonObj, "quantity"); - obj.amount = JsonUtil.getLong(json, "amount"); + obj.amount = JsonUtil.getLong(jsonObj, "amount"); - obj.currencyCode = JsonUtil.getString(json, "currency_code"); + obj.currencyCode = JsonUtil.getString(jsonObj, "currency_code"); - obj.discountAmount = JsonUtil.getLong(json, "discount_amount"); + obj.discountAmount = JsonUtil.getLong(jsonObj, "discount_amount"); - obj.description = JsonUtil.getString(json, "description"); + obj.description = JsonUtil.getString(jsonObj, "description"); - obj.entityType = EntityType.fromString(JsonUtil.getString(json, "entity_type")); + obj.entityType = EntityType.fromString(JsonUtil.getString(jsonObj, "entity_type")); - obj.entityId = JsonUtil.getString(json, "entity_id"); + obj.entityId = JsonUtil.getString(jsonObj, "entity_id"); - obj.isVoided = JsonUtil.getBoolean(json, "is_voided"); + obj.isVoided = JsonUtil.getBoolean(jsonObj, "is_voided"); - obj.voidedAt = JsonUtil.getTimestamp(json, "voided_at"); + obj.voidedAt = JsonUtil.getTimestamp(jsonObj, "voided_at"); - obj.unitAmountInDecimal = JsonUtil.getString(json, "unit_amount_in_decimal"); + obj.unitAmountInDecimal = JsonUtil.getString(jsonObj, "unit_amount_in_decimal"); - obj.quantityInDecimal = JsonUtil.getString(json, "quantity_in_decimal"); + obj.quantityInDecimal = JsonUtil.getString(jsonObj, "quantity_in_decimal"); - obj.amountInDecimal = JsonUtil.getString(json, "amount_in_decimal"); + obj.amountInDecimal = JsonUtil.getString(jsonObj, "amount_in_decimal"); - obj.updatedAt = JsonUtil.getTimestamp(json, "updated_at"); + obj.updatedAt = JsonUtil.getTimestamp(jsonObj, "updated_at"); - obj.tiers = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "tiers")).stream() - .map(Tiers::fromJson) - .collect(java.util.stream.Collectors.toList()); + obj.tiers = JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "tiers"), Tiers::fromJson); - obj.isAdvanceCharge = JsonUtil.getBoolean(json, "is_advance_charge"); + obj.isAdvanceCharge = JsonUtil.getBoolean(jsonObj, "is_advance_charge"); - obj.businessEntityId = JsonUtil.getString(json, "business_entity_id"); + obj.businessEntityId = JsonUtil.getString(jsonObj, "business_entity_id"); - obj.deleted = JsonUtil.getBoolean(json, "deleted"); + obj.deleted = JsonUtil.getBoolean(jsonObj, "deleted"); return obj; } @@ -8875,29 +9004,33 @@ public static PricingType fromString(String value) { } public static Tiers fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Tiers fromJson(JsonObject jsonObj) { Tiers obj = new Tiers(); - obj.lineItemId = JsonUtil.getString(json, "line_item_id"); + obj.lineItemId = JsonUtil.getString(jsonObj, "line_item_id"); - obj.startingUnit = JsonUtil.getInteger(json, "starting_unit"); + obj.startingUnit = JsonUtil.getInteger(jsonObj, "starting_unit"); - obj.endingUnit = JsonUtil.getInteger(json, "ending_unit"); + obj.endingUnit = JsonUtil.getInteger(jsonObj, "ending_unit"); - obj.quantityUsed = JsonUtil.getInteger(json, "quantity_used"); + obj.quantityUsed = JsonUtil.getInteger(jsonObj, "quantity_used"); - obj.unitAmount = JsonUtil.getLong(json, "unit_amount"); + obj.unitAmount = JsonUtil.getLong(jsonObj, "unit_amount"); - obj.startingUnitInDecimal = JsonUtil.getString(json, "starting_unit_in_decimal"); + obj.startingUnitInDecimal = JsonUtil.getString(jsonObj, "starting_unit_in_decimal"); - obj.endingUnitInDecimal = JsonUtil.getString(json, "ending_unit_in_decimal"); + obj.endingUnitInDecimal = JsonUtil.getString(jsonObj, "ending_unit_in_decimal"); - obj.quantityUsedInDecimal = JsonUtil.getString(json, "quantity_used_in_decimal"); + obj.quantityUsedInDecimal = JsonUtil.getString(jsonObj, "quantity_used_in_decimal"); - obj.unitAmountInDecimal = JsonUtil.getString(json, "unit_amount_in_decimal"); + obj.unitAmountInDecimal = JsonUtil.getString(jsonObj, "unit_amount_in_decimal"); - obj.pricingType = PricingType.fromString(JsonUtil.getString(json, "pricing_type")); + obj.pricingType = PricingType.fromString(JsonUtil.getString(jsonObj, "pricing_type")); - obj.packageSize = JsonUtil.getInteger(json, "package_size"); + obj.packageSize = JsonUtil.getInteger(jsonObj, "package_size"); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/estimate/responses/AdvanceInvoiceEstimateResponse.java b/src/main/java/com/chargebee/v4/models/estimate/responses/AdvanceInvoiceEstimateResponse.java index 4c99e7ce..4dad2929 100644 --- a/src/main/java/com/chargebee/v4/models/estimate/responses/AdvanceInvoiceEstimateResponse.java +++ b/src/main/java/com/chargebee/v4/models/estimate/responses/AdvanceInvoiceEstimateResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static AdvanceInvoiceEstimateResponse fromJson(String json) { /** Parse JSON response into AdvanceInvoiceEstimateResponse object with HTTP response. */ public static AdvanceInvoiceEstimateResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __estimateJson = JsonUtil.getObject(json, "estimate"); - if (__estimateJson != null) { - builder.estimate(Estimate.fromJson(__estimateJson)); + JsonObject __estimateObj = JsonUtil.getJsonObject(jsonObj, "estimate"); + if (__estimateObj != null) { + builder.estimate(Estimate.fromJson(__estimateObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/estimate/responses/CreateSubscriptionForCustomerEstimateResponse.java b/src/main/java/com/chargebee/v4/models/estimate/responses/CreateSubscriptionForCustomerEstimateResponse.java index e596a1d6..68efac54 100644 --- a/src/main/java/com/chargebee/v4/models/estimate/responses/CreateSubscriptionForCustomerEstimateResponse.java +++ b/src/main/java/com/chargebee/v4/models/estimate/responses/CreateSubscriptionForCustomerEstimateResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -31,11 +32,12 @@ public static CreateSubscriptionForCustomerEstimateResponse fromJson(String json public static CreateSubscriptionForCustomerEstimateResponse fromJson( String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __estimateJson = JsonUtil.getObject(json, "estimate"); - if (__estimateJson != null) { - builder.estimate(Estimate.fromJson(__estimateJson)); + JsonObject __estimateObj = JsonUtil.getJsonObject(jsonObj, "estimate"); + if (__estimateObj != null) { + builder.estimate(Estimate.fromJson(__estimateObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/estimate/responses/CreateSubscriptionItemEstimateResponse.java b/src/main/java/com/chargebee/v4/models/estimate/responses/CreateSubscriptionItemEstimateResponse.java index fb810528..eaa3ebee 100644 --- a/src/main/java/com/chargebee/v4/models/estimate/responses/CreateSubscriptionItemEstimateResponse.java +++ b/src/main/java/com/chargebee/v4/models/estimate/responses/CreateSubscriptionItemEstimateResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -28,11 +29,12 @@ public static CreateSubscriptionItemEstimateResponse fromJson(String json) { public static CreateSubscriptionItemEstimateResponse fromJson( String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __estimateJson = JsonUtil.getObject(json, "estimate"); - if (__estimateJson != null) { - builder.estimate(Estimate.fromJson(__estimateJson)); + JsonObject __estimateObj = JsonUtil.getJsonObject(jsonObj, "estimate"); + if (__estimateObj != null) { + builder.estimate(Estimate.fromJson(__estimateObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/estimate/responses/CreateSubscriptionItemForCustomerEstimateResponse.java b/src/main/java/com/chargebee/v4/models/estimate/responses/CreateSubscriptionItemForCustomerEstimateResponse.java index ba7512a9..9851826f 100644 --- a/src/main/java/com/chargebee/v4/models/estimate/responses/CreateSubscriptionItemForCustomerEstimateResponse.java +++ b/src/main/java/com/chargebee/v4/models/estimate/responses/CreateSubscriptionItemForCustomerEstimateResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -31,11 +32,12 @@ public static CreateSubscriptionItemForCustomerEstimateResponse fromJson(String public static CreateSubscriptionItemForCustomerEstimateResponse fromJson( String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __estimateJson = JsonUtil.getObject(json, "estimate"); - if (__estimateJson != null) { - builder.estimate(Estimate.fromJson(__estimateJson)); + JsonObject __estimateObj = JsonUtil.getJsonObject(jsonObj, "estimate"); + if (__estimateObj != null) { + builder.estimate(Estimate.fromJson(__estimateObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/estimate/responses/EstimateCancelSubscriptionForItemsResponse.java b/src/main/java/com/chargebee/v4/models/estimate/responses/EstimateCancelSubscriptionForItemsResponse.java index 8570b6f0..65c93be0 100644 --- a/src/main/java/com/chargebee/v4/models/estimate/responses/EstimateCancelSubscriptionForItemsResponse.java +++ b/src/main/java/com/chargebee/v4/models/estimate/responses/EstimateCancelSubscriptionForItemsResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -30,11 +31,12 @@ public static EstimateCancelSubscriptionForItemsResponse fromJson(String json) { public static EstimateCancelSubscriptionForItemsResponse fromJson( String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __estimateJson = JsonUtil.getObject(json, "estimate"); - if (__estimateJson != null) { - builder.estimate(Estimate.fromJson(__estimateJson)); + JsonObject __estimateObj = JsonUtil.getJsonObject(jsonObj, "estimate"); + if (__estimateObj != null) { + builder.estimate(Estimate.fromJson(__estimateObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/estimate/responses/EstimateCancelSubscriptionResponse.java b/src/main/java/com/chargebee/v4/models/estimate/responses/EstimateCancelSubscriptionResponse.java index 77eeb9ff..a746e190 100644 --- a/src/main/java/com/chargebee/v4/models/estimate/responses/EstimateCancelSubscriptionResponse.java +++ b/src/main/java/com/chargebee/v4/models/estimate/responses/EstimateCancelSubscriptionResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static EstimateCancelSubscriptionResponse fromJson(String json) { /** Parse JSON response into EstimateCancelSubscriptionResponse object with HTTP response. */ public static EstimateCancelSubscriptionResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __estimateJson = JsonUtil.getObject(json, "estimate"); - if (__estimateJson != null) { - builder.estimate(Estimate.fromJson(__estimateJson)); + JsonObject __estimateObj = JsonUtil.getJsonObject(jsonObj, "estimate"); + if (__estimateObj != null) { + builder.estimate(Estimate.fromJson(__estimateObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/estimate/responses/EstimateChangeTermEndResponse.java b/src/main/java/com/chargebee/v4/models/estimate/responses/EstimateChangeTermEndResponse.java index 9ef0112b..bce4ea38 100644 --- a/src/main/java/com/chargebee/v4/models/estimate/responses/EstimateChangeTermEndResponse.java +++ b/src/main/java/com/chargebee/v4/models/estimate/responses/EstimateChangeTermEndResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static EstimateChangeTermEndResponse fromJson(String json) { /** Parse JSON response into EstimateChangeTermEndResponse object with HTTP response. */ public static EstimateChangeTermEndResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __estimateJson = JsonUtil.getObject(json, "estimate"); - if (__estimateJson != null) { - builder.estimate(Estimate.fromJson(__estimateJson)); + JsonObject __estimateObj = JsonUtil.getJsonObject(jsonObj, "estimate"); + if (__estimateObj != null) { + builder.estimate(Estimate.fromJson(__estimateObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/estimate/responses/EstimateCreateInvoiceForItemsResponse.java b/src/main/java/com/chargebee/v4/models/estimate/responses/EstimateCreateInvoiceForItemsResponse.java index 6c01a084..837ab7f0 100644 --- a/src/main/java/com/chargebee/v4/models/estimate/responses/EstimateCreateInvoiceForItemsResponse.java +++ b/src/main/java/com/chargebee/v4/models/estimate/responses/EstimateCreateInvoiceForItemsResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static EstimateCreateInvoiceForItemsResponse fromJson(String json) { /** Parse JSON response into EstimateCreateInvoiceForItemsResponse object with HTTP response. */ public static EstimateCreateInvoiceForItemsResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __estimateJson = JsonUtil.getObject(json, "estimate"); - if (__estimateJson != null) { - builder.estimate(Estimate.fromJson(__estimateJson)); + JsonObject __estimateObj = JsonUtil.getJsonObject(jsonObj, "estimate"); + if (__estimateObj != null) { + builder.estimate(Estimate.fromJson(__estimateObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/estimate/responses/EstimateCreateInvoiceResponse.java b/src/main/java/com/chargebee/v4/models/estimate/responses/EstimateCreateInvoiceResponse.java index 50513500..be46b915 100644 --- a/src/main/java/com/chargebee/v4/models/estimate/responses/EstimateCreateInvoiceResponse.java +++ b/src/main/java/com/chargebee/v4/models/estimate/responses/EstimateCreateInvoiceResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static EstimateCreateInvoiceResponse fromJson(String json) { /** Parse JSON response into EstimateCreateInvoiceResponse object with HTTP response. */ public static EstimateCreateInvoiceResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __estimateJson = JsonUtil.getObject(json, "estimate"); - if (__estimateJson != null) { - builder.estimate(Estimate.fromJson(__estimateJson)); + JsonObject __estimateObj = JsonUtil.getJsonObject(jsonObj, "estimate"); + if (__estimateObj != null) { + builder.estimate(Estimate.fromJson(__estimateObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/estimate/responses/EstimateCreateSubscriptionResponse.java b/src/main/java/com/chargebee/v4/models/estimate/responses/EstimateCreateSubscriptionResponse.java index f6aab272..7fb54c7a 100644 --- a/src/main/java/com/chargebee/v4/models/estimate/responses/EstimateCreateSubscriptionResponse.java +++ b/src/main/java/com/chargebee/v4/models/estimate/responses/EstimateCreateSubscriptionResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static EstimateCreateSubscriptionResponse fromJson(String json) { /** Parse JSON response into EstimateCreateSubscriptionResponse object with HTTP response. */ public static EstimateCreateSubscriptionResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __estimateJson = JsonUtil.getObject(json, "estimate"); - if (__estimateJson != null) { - builder.estimate(Estimate.fromJson(__estimateJson)); + JsonObject __estimateObj = JsonUtil.getJsonObject(jsonObj, "estimate"); + if (__estimateObj != null) { + builder.estimate(Estimate.fromJson(__estimateObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/estimate/responses/EstimateGiftSubscriptionForItemsResponse.java b/src/main/java/com/chargebee/v4/models/estimate/responses/EstimateGiftSubscriptionForItemsResponse.java index ea8fe2e5..bb093b92 100644 --- a/src/main/java/com/chargebee/v4/models/estimate/responses/EstimateGiftSubscriptionForItemsResponse.java +++ b/src/main/java/com/chargebee/v4/models/estimate/responses/EstimateGiftSubscriptionForItemsResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -30,11 +31,12 @@ public static EstimateGiftSubscriptionForItemsResponse fromJson(String json) { public static EstimateGiftSubscriptionForItemsResponse fromJson( String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __estimateJson = JsonUtil.getObject(json, "estimate"); - if (__estimateJson != null) { - builder.estimate(Estimate.fromJson(__estimateJson)); + JsonObject __estimateObj = JsonUtil.getJsonObject(jsonObj, "estimate"); + if (__estimateObj != null) { + builder.estimate(Estimate.fromJson(__estimateObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/estimate/responses/EstimateGiftSubscriptionResponse.java b/src/main/java/com/chargebee/v4/models/estimate/responses/EstimateGiftSubscriptionResponse.java index 3264ce13..aa3eec6d 100644 --- a/src/main/java/com/chargebee/v4/models/estimate/responses/EstimateGiftSubscriptionResponse.java +++ b/src/main/java/com/chargebee/v4/models/estimate/responses/EstimateGiftSubscriptionResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static EstimateGiftSubscriptionResponse fromJson(String json) { /** Parse JSON response into EstimateGiftSubscriptionResponse object with HTTP response. */ public static EstimateGiftSubscriptionResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __estimateJson = JsonUtil.getObject(json, "estimate"); - if (__estimateJson != null) { - builder.estimate(Estimate.fromJson(__estimateJson)); + JsonObject __estimateObj = JsonUtil.getJsonObject(jsonObj, "estimate"); + if (__estimateObj != null) { + builder.estimate(Estimate.fromJson(__estimateObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/estimate/responses/EstimatePauseSubscriptionResponse.java b/src/main/java/com/chargebee/v4/models/estimate/responses/EstimatePauseSubscriptionResponse.java index f818daa2..675b91ae 100644 --- a/src/main/java/com/chargebee/v4/models/estimate/responses/EstimatePauseSubscriptionResponse.java +++ b/src/main/java/com/chargebee/v4/models/estimate/responses/EstimatePauseSubscriptionResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static EstimatePauseSubscriptionResponse fromJson(String json) { /** Parse JSON response into EstimatePauseSubscriptionResponse object with HTTP response. */ public static EstimatePauseSubscriptionResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __estimateJson = JsonUtil.getObject(json, "estimate"); - if (__estimateJson != null) { - builder.estimate(Estimate.fromJson(__estimateJson)); + JsonObject __estimateObj = JsonUtil.getJsonObject(jsonObj, "estimate"); + if (__estimateObj != null) { + builder.estimate(Estimate.fromJson(__estimateObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/estimate/responses/EstimatePaymentSchedulesResponse.java b/src/main/java/com/chargebee/v4/models/estimate/responses/EstimatePaymentSchedulesResponse.java index 6e7fc476..e4e029bc 100644 --- a/src/main/java/com/chargebee/v4/models/estimate/responses/EstimatePaymentSchedulesResponse.java +++ b/src/main/java/com/chargebee/v4/models/estimate/responses/EstimatePaymentSchedulesResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static EstimatePaymentSchedulesResponse fromJson(String json) { /** Parse JSON response into EstimatePaymentSchedulesResponse object with HTTP response. */ public static EstimatePaymentSchedulesResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __estimateJson = JsonUtil.getObject(json, "estimate"); - if (__estimateJson != null) { - builder.estimate(Estimate.fromJson(__estimateJson)); + JsonObject __estimateObj = JsonUtil.getJsonObject(jsonObj, "estimate"); + if (__estimateObj != null) { + builder.estimate(Estimate.fromJson(__estimateObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/estimate/responses/EstimateResumeSubscriptionResponse.java b/src/main/java/com/chargebee/v4/models/estimate/responses/EstimateResumeSubscriptionResponse.java index edbc85dc..9448f5f5 100644 --- a/src/main/java/com/chargebee/v4/models/estimate/responses/EstimateResumeSubscriptionResponse.java +++ b/src/main/java/com/chargebee/v4/models/estimate/responses/EstimateResumeSubscriptionResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static EstimateResumeSubscriptionResponse fromJson(String json) { /** Parse JSON response into EstimateResumeSubscriptionResponse object with HTTP response. */ public static EstimateResumeSubscriptionResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __estimateJson = JsonUtil.getObject(json, "estimate"); - if (__estimateJson != null) { - builder.estimate(Estimate.fromJson(__estimateJson)); + JsonObject __estimateObj = JsonUtil.getJsonObject(jsonObj, "estimate"); + if (__estimateObj != null) { + builder.estimate(Estimate.fromJson(__estimateObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/estimate/responses/EstimateUpdateSubscriptionForItemsResponse.java b/src/main/java/com/chargebee/v4/models/estimate/responses/EstimateUpdateSubscriptionForItemsResponse.java index 12e253b7..5477ec30 100644 --- a/src/main/java/com/chargebee/v4/models/estimate/responses/EstimateUpdateSubscriptionForItemsResponse.java +++ b/src/main/java/com/chargebee/v4/models/estimate/responses/EstimateUpdateSubscriptionForItemsResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -30,11 +31,12 @@ public static EstimateUpdateSubscriptionForItemsResponse fromJson(String json) { public static EstimateUpdateSubscriptionForItemsResponse fromJson( String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __estimateJson = JsonUtil.getObject(json, "estimate"); - if (__estimateJson != null) { - builder.estimate(Estimate.fromJson(__estimateJson)); + JsonObject __estimateObj = JsonUtil.getJsonObject(jsonObj, "estimate"); + if (__estimateObj != null) { + builder.estimate(Estimate.fromJson(__estimateObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/estimate/responses/EstimateUpdateSubscriptionResponse.java b/src/main/java/com/chargebee/v4/models/estimate/responses/EstimateUpdateSubscriptionResponse.java index 443df115..1a3afb5b 100644 --- a/src/main/java/com/chargebee/v4/models/estimate/responses/EstimateUpdateSubscriptionResponse.java +++ b/src/main/java/com/chargebee/v4/models/estimate/responses/EstimateUpdateSubscriptionResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static EstimateUpdateSubscriptionResponse fromJson(String json) { /** Parse JSON response into EstimateUpdateSubscriptionResponse object with HTTP response. */ public static EstimateUpdateSubscriptionResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __estimateJson = JsonUtil.getObject(json, "estimate"); - if (__estimateJson != null) { - builder.estimate(Estimate.fromJson(__estimateJson)); + JsonObject __estimateObj = JsonUtil.getJsonObject(jsonObj, "estimate"); + if (__estimateObj != null) { + builder.estimate(Estimate.fromJson(__estimateObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/estimate/responses/RegenerateInvoiceEstimateResponse.java b/src/main/java/com/chargebee/v4/models/estimate/responses/RegenerateInvoiceEstimateResponse.java index a8a7c135..5ed4dd59 100644 --- a/src/main/java/com/chargebee/v4/models/estimate/responses/RegenerateInvoiceEstimateResponse.java +++ b/src/main/java/com/chargebee/v4/models/estimate/responses/RegenerateInvoiceEstimateResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static RegenerateInvoiceEstimateResponse fromJson(String json) { /** Parse JSON response into RegenerateInvoiceEstimateResponse object with HTTP response. */ public static RegenerateInvoiceEstimateResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __estimateJson = JsonUtil.getObject(json, "estimate"); - if (__estimateJson != null) { - builder.estimate(Estimate.fromJson(__estimateJson)); + JsonObject __estimateObj = JsonUtil.getJsonObject(jsonObj, "estimate"); + if (__estimateObj != null) { + builder.estimate(Estimate.fromJson(__estimateObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/estimate/responses/RenewalEstimateResponse.java b/src/main/java/com/chargebee/v4/models/estimate/responses/RenewalEstimateResponse.java index 23686180..9ca682ea 100644 --- a/src/main/java/com/chargebee/v4/models/estimate/responses/RenewalEstimateResponse.java +++ b/src/main/java/com/chargebee/v4/models/estimate/responses/RenewalEstimateResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static RenewalEstimateResponse fromJson(String json) { /** Parse JSON response into RenewalEstimateResponse object with HTTP response. */ public static RenewalEstimateResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __estimateJson = JsonUtil.getObject(json, "estimate"); - if (__estimateJson != null) { - builder.estimate(Estimate.fromJson(__estimateJson)); + JsonObject __estimateObj = JsonUtil.getJsonObject(jsonObj, "estimate"); + if (__estimateObj != null) { + builder.estimate(Estimate.fromJson(__estimateObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/estimate/responses/UpcomingInvoicesEstimateResponse.java b/src/main/java/com/chargebee/v4/models/estimate/responses/UpcomingInvoicesEstimateResponse.java index 3cf92408..721a27cb 100644 --- a/src/main/java/com/chargebee/v4/models/estimate/responses/UpcomingInvoicesEstimateResponse.java +++ b/src/main/java/com/chargebee/v4/models/estimate/responses/UpcomingInvoicesEstimateResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static UpcomingInvoicesEstimateResponse fromJson(String json) { /** Parse JSON response into UpcomingInvoicesEstimateResponse object with HTTP response. */ public static UpcomingInvoicesEstimateResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __estimateJson = JsonUtil.getObject(json, "estimate"); - if (__estimateJson != null) { - builder.estimate(Estimate.fromJson(__estimateJson)); + JsonObject __estimateObj = JsonUtil.getJsonObject(jsonObj, "estimate"); + if (__estimateObj != null) { + builder.estimate(Estimate.fromJson(__estimateObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/event/AddUsagesReminderEvent.java b/src/main/java/com/chargebee/v4/models/event/AddUsagesReminderEvent.java index 2c344c44..dae179ce 100644 --- a/src/main/java/com/chargebee/v4/models/event/AddUsagesReminderEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/AddUsagesReminderEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.customer.Customer; @@ -59,25 +60,29 @@ public Content getContent() { } public static AddUsagesReminderEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static AddUsagesReminderEvent fromJson(JsonObject jsonObj) { AddUsagesReminderEvent obj = new AddUsagesReminderEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -147,21 +152,25 @@ public UsageReminderInfo getUsageReminderInfo() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __subscriptionJson = JsonUtil.getObject(json, "subscription"); - if (__subscriptionJson != null) { - obj.subscription = Subscription.fromJson(__subscriptionJson); + JsonObject __subscriptionObj = JsonUtil.getJsonObject(jsonObj, "subscription"); + if (__subscriptionObj != null) { + obj.subscription = Subscription.fromJson(__subscriptionObj); } - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - obj.customer = Customer.fromJson(__customerJson); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + obj.customer = Customer.fromJson(__customerObj); } - String __usageReminderInfoJson = JsonUtil.getObject(json, "usage_reminder_info"); - if (__usageReminderInfoJson != null) { - obj.usageReminderInfo = UsageReminderInfo.fromJson(__usageReminderInfoJson); + JsonObject __usageReminderInfoObj = JsonUtil.getJsonObject(jsonObj, "usage_reminder_info"); + if (__usageReminderInfoObj != null) { + obj.usageReminderInfo = UsageReminderInfo.fromJson(__usageReminderInfoObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/AddonCreatedEvent.java b/src/main/java/com/chargebee/v4/models/event/AddonCreatedEvent.java index 9e14c81e..73851a4e 100644 --- a/src/main/java/com/chargebee/v4/models/event/AddonCreatedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/AddonCreatedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.addon.Addon; @@ -55,25 +56,29 @@ public Content getContent() { } public static AddonCreatedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static AddonCreatedEvent fromJson(JsonObject jsonObj) { AddonCreatedEvent obj = new AddonCreatedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -133,11 +138,15 @@ public Addon getAddon() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __addonJson = JsonUtil.getObject(json, "addon"); - if (__addonJson != null) { - obj.addon = Addon.fromJson(__addonJson); + JsonObject __addonObj = JsonUtil.getJsonObject(jsonObj, "addon"); + if (__addonObj != null) { + obj.addon = Addon.fromJson(__addonObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/AddonDeletedEvent.java b/src/main/java/com/chargebee/v4/models/event/AddonDeletedEvent.java index b2d9c44a..70cc8ae9 100644 --- a/src/main/java/com/chargebee/v4/models/event/AddonDeletedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/AddonDeletedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.addon.Addon; @@ -55,25 +56,29 @@ public Content getContent() { } public static AddonDeletedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static AddonDeletedEvent fromJson(JsonObject jsonObj) { AddonDeletedEvent obj = new AddonDeletedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -133,11 +138,15 @@ public Addon getAddon() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __addonJson = JsonUtil.getObject(json, "addon"); - if (__addonJson != null) { - obj.addon = Addon.fromJson(__addonJson); + JsonObject __addonObj = JsonUtil.getJsonObject(jsonObj, "addon"); + if (__addonObj != null) { + obj.addon = Addon.fromJson(__addonObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/AddonUpdatedEvent.java b/src/main/java/com/chargebee/v4/models/event/AddonUpdatedEvent.java index b8c5dc3a..73050655 100644 --- a/src/main/java/com/chargebee/v4/models/event/AddonUpdatedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/AddonUpdatedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.addon.Addon; @@ -55,25 +56,29 @@ public Content getContent() { } public static AddonUpdatedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static AddonUpdatedEvent fromJson(JsonObject jsonObj) { AddonUpdatedEvent obj = new AddonUpdatedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -133,11 +138,15 @@ public Addon getAddon() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __addonJson = JsonUtil.getObject(json, "addon"); - if (__addonJson != null) { - obj.addon = Addon.fromJson(__addonJson); + JsonObject __addonObj = JsonUtil.getJsonObject(jsonObj, "addon"); + if (__addonObj != null) { + obj.addon = Addon.fromJson(__addonObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/AttachedItemCreatedEvent.java b/src/main/java/com/chargebee/v4/models/event/AttachedItemCreatedEvent.java index 0e655295..aeaa830d 100644 --- a/src/main/java/com/chargebee/v4/models/event/AttachedItemCreatedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/AttachedItemCreatedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.attachedItem.AttachedItem; @@ -55,25 +56,29 @@ public Content getContent() { } public static AttachedItemCreatedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static AttachedItemCreatedEvent fromJson(JsonObject jsonObj) { AttachedItemCreatedEvent obj = new AttachedItemCreatedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -133,11 +138,15 @@ public AttachedItem getAttachedItem() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __attachedItemJson = JsonUtil.getObject(json, "attached_item"); - if (__attachedItemJson != null) { - obj.attachedItem = AttachedItem.fromJson(__attachedItemJson); + JsonObject __attachedItemObj = JsonUtil.getJsonObject(jsonObj, "attached_item"); + if (__attachedItemObj != null) { + obj.attachedItem = AttachedItem.fromJson(__attachedItemObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/AttachedItemDeletedEvent.java b/src/main/java/com/chargebee/v4/models/event/AttachedItemDeletedEvent.java index 6c7752fa..c5819ad6 100644 --- a/src/main/java/com/chargebee/v4/models/event/AttachedItemDeletedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/AttachedItemDeletedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.attachedItem.AttachedItem; @@ -55,25 +56,29 @@ public Content getContent() { } public static AttachedItemDeletedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static AttachedItemDeletedEvent fromJson(JsonObject jsonObj) { AttachedItemDeletedEvent obj = new AttachedItemDeletedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -133,11 +138,15 @@ public AttachedItem getAttachedItem() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __attachedItemJson = JsonUtil.getObject(json, "attached_item"); - if (__attachedItemJson != null) { - obj.attachedItem = AttachedItem.fromJson(__attachedItemJson); + JsonObject __attachedItemObj = JsonUtil.getJsonObject(jsonObj, "attached_item"); + if (__attachedItemObj != null) { + obj.attachedItem = AttachedItem.fromJson(__attachedItemObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/AttachedItemUpdatedEvent.java b/src/main/java/com/chargebee/v4/models/event/AttachedItemUpdatedEvent.java index 93324f48..23ecf09b 100644 --- a/src/main/java/com/chargebee/v4/models/event/AttachedItemUpdatedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/AttachedItemUpdatedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.attachedItem.AttachedItem; @@ -55,25 +56,29 @@ public Content getContent() { } public static AttachedItemUpdatedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static AttachedItemUpdatedEvent fromJson(JsonObject jsonObj) { AttachedItemUpdatedEvent obj = new AttachedItemUpdatedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -133,11 +138,15 @@ public AttachedItem getAttachedItem() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __attachedItemJson = JsonUtil.getObject(json, "attached_item"); - if (__attachedItemJson != null) { - obj.attachedItem = AttachedItem.fromJson(__attachedItemJson); + JsonObject __attachedItemObj = JsonUtil.getJsonObject(jsonObj, "attached_item"); + if (__attachedItemObj != null) { + obj.attachedItem = AttachedItem.fromJson(__attachedItemObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/AuthorizationSucceededEvent.java b/src/main/java/com/chargebee/v4/models/event/AuthorizationSucceededEvent.java index 0f5507fa..53dd5fc6 100644 --- a/src/main/java/com/chargebee/v4/models/event/AuthorizationSucceededEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/AuthorizationSucceededEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.transaction.Transaction; @@ -55,25 +56,29 @@ public Content getContent() { } public static AuthorizationSucceededEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static AuthorizationSucceededEvent fromJson(JsonObject jsonObj) { AuthorizationSucceededEvent obj = new AuthorizationSucceededEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -133,11 +138,15 @@ public Transaction getTransaction() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __transactionJson = JsonUtil.getObject(json, "transaction"); - if (__transactionJson != null) { - obj.transaction = Transaction.fromJson(__transactionJson); + JsonObject __transactionObj = JsonUtil.getJsonObject(jsonObj, "transaction"); + if (__transactionObj != null) { + obj.transaction = Transaction.fromJson(__transactionObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/AuthorizationVoidedEvent.java b/src/main/java/com/chargebee/v4/models/event/AuthorizationVoidedEvent.java index 4493f03e..c8876a00 100644 --- a/src/main/java/com/chargebee/v4/models/event/AuthorizationVoidedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/AuthorizationVoidedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.transaction.Transaction; @@ -55,25 +56,29 @@ public Content getContent() { } public static AuthorizationVoidedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static AuthorizationVoidedEvent fromJson(JsonObject jsonObj) { AuthorizationVoidedEvent obj = new AuthorizationVoidedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -133,11 +138,15 @@ public Transaction getTransaction() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __transactionJson = JsonUtil.getObject(json, "transaction"); - if (__transactionJson != null) { - obj.transaction = Transaction.fromJson(__transactionJson); + JsonObject __transactionObj = JsonUtil.getJsonObject(jsonObj, "transaction"); + if (__transactionObj != null) { + obj.transaction = Transaction.fromJson(__transactionObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/BusinessEntityCreatedEvent.java b/src/main/java/com/chargebee/v4/models/event/BusinessEntityCreatedEvent.java index 7e80bed2..a02f2d87 100644 --- a/src/main/java/com/chargebee/v4/models/event/BusinessEntityCreatedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/BusinessEntityCreatedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.businessEntity.BusinessEntity; @@ -55,25 +56,29 @@ public Content getContent() { } public static BusinessEntityCreatedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static BusinessEntityCreatedEvent fromJson(JsonObject jsonObj) { BusinessEntityCreatedEvent obj = new BusinessEntityCreatedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -133,11 +138,15 @@ public BusinessEntity getBusinessEntity() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __businessEntityJson = JsonUtil.getObject(json, "business_entity"); - if (__businessEntityJson != null) { - obj.businessEntity = BusinessEntity.fromJson(__businessEntityJson); + JsonObject __businessEntityObj = JsonUtil.getJsonObject(jsonObj, "business_entity"); + if (__businessEntityObj != null) { + obj.businessEntity = BusinessEntity.fromJson(__businessEntityObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/BusinessEntityDeletedEvent.java b/src/main/java/com/chargebee/v4/models/event/BusinessEntityDeletedEvent.java index 0cab0d16..257c6804 100644 --- a/src/main/java/com/chargebee/v4/models/event/BusinessEntityDeletedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/BusinessEntityDeletedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.businessEntity.BusinessEntity; @@ -55,25 +56,29 @@ public Content getContent() { } public static BusinessEntityDeletedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static BusinessEntityDeletedEvent fromJson(JsonObject jsonObj) { BusinessEntityDeletedEvent obj = new BusinessEntityDeletedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -133,11 +138,15 @@ public BusinessEntity getBusinessEntity() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __businessEntityJson = JsonUtil.getObject(json, "business_entity"); - if (__businessEntityJson != null) { - obj.businessEntity = BusinessEntity.fromJson(__businessEntityJson); + JsonObject __businessEntityObj = JsonUtil.getJsonObject(jsonObj, "business_entity"); + if (__businessEntityObj != null) { + obj.businessEntity = BusinessEntity.fromJson(__businessEntityObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/BusinessEntityUpdatedEvent.java b/src/main/java/com/chargebee/v4/models/event/BusinessEntityUpdatedEvent.java index 94cfc503..2f1a83e7 100644 --- a/src/main/java/com/chargebee/v4/models/event/BusinessEntityUpdatedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/BusinessEntityUpdatedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.businessEntity.BusinessEntity; @@ -55,25 +56,29 @@ public Content getContent() { } public static BusinessEntityUpdatedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static BusinessEntityUpdatedEvent fromJson(JsonObject jsonObj) { BusinessEntityUpdatedEvent obj = new BusinessEntityUpdatedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -133,11 +138,15 @@ public BusinessEntity getBusinessEntity() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __businessEntityJson = JsonUtil.getObject(json, "business_entity"); - if (__businessEntityJson != null) { - obj.businessEntity = BusinessEntity.fromJson(__businessEntityJson); + JsonObject __businessEntityObj = JsonUtil.getJsonObject(jsonObj, "business_entity"); + if (__businessEntityObj != null) { + obj.businessEntity = BusinessEntity.fromJson(__businessEntityObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/CardAddedEvent.java b/src/main/java/com/chargebee/v4/models/event/CardAddedEvent.java index 8cc1f0e5..d3da32be 100644 --- a/src/main/java/com/chargebee/v4/models/event/CardAddedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/CardAddedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.customer.Customer; @@ -57,25 +58,29 @@ public Content getContent() { } public static CardAddedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static CardAddedEvent fromJson(JsonObject jsonObj) { CardAddedEvent obj = new CardAddedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -140,16 +145,20 @@ public Card getCard() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - obj.customer = Customer.fromJson(__customerJson); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + obj.customer = Customer.fromJson(__customerObj); } - String __cardJson = JsonUtil.getObject(json, "card"); - if (__cardJson != null) { - obj.card = Card.fromJson(__cardJson); + JsonObject __cardObj = JsonUtil.getJsonObject(jsonObj, "card"); + if (__cardObj != null) { + obj.card = Card.fromJson(__cardObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/CardDeletedEvent.java b/src/main/java/com/chargebee/v4/models/event/CardDeletedEvent.java index 7c3122e9..76d62dd1 100644 --- a/src/main/java/com/chargebee/v4/models/event/CardDeletedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/CardDeletedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.customer.Customer; @@ -57,25 +58,29 @@ public Content getContent() { } public static CardDeletedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static CardDeletedEvent fromJson(JsonObject jsonObj) { CardDeletedEvent obj = new CardDeletedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -140,16 +145,20 @@ public Card getCard() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - obj.customer = Customer.fromJson(__customerJson); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + obj.customer = Customer.fromJson(__customerObj); } - String __cardJson = JsonUtil.getObject(json, "card"); - if (__cardJson != null) { - obj.card = Card.fromJson(__cardJson); + JsonObject __cardObj = JsonUtil.getJsonObject(jsonObj, "card"); + if (__cardObj != null) { + obj.card = Card.fromJson(__cardObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/CardExpiredEvent.java b/src/main/java/com/chargebee/v4/models/event/CardExpiredEvent.java index 5f07aceb..ec10b73e 100644 --- a/src/main/java/com/chargebee/v4/models/event/CardExpiredEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/CardExpiredEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.customer.Customer; @@ -57,25 +58,29 @@ public Content getContent() { } public static CardExpiredEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static CardExpiredEvent fromJson(JsonObject jsonObj) { CardExpiredEvent obj = new CardExpiredEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -140,16 +145,20 @@ public Card getCard() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - obj.customer = Customer.fromJson(__customerJson); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + obj.customer = Customer.fromJson(__customerObj); } - String __cardJson = JsonUtil.getObject(json, "card"); - if (__cardJson != null) { - obj.card = Card.fromJson(__cardJson); + JsonObject __cardObj = JsonUtil.getJsonObject(jsonObj, "card"); + if (__cardObj != null) { + obj.card = Card.fromJson(__cardObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/CardExpiryReminderEvent.java b/src/main/java/com/chargebee/v4/models/event/CardExpiryReminderEvent.java index 1c41ba26..d11fbe94 100644 --- a/src/main/java/com/chargebee/v4/models/event/CardExpiryReminderEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/CardExpiryReminderEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.customer.Customer; @@ -57,25 +58,29 @@ public Content getContent() { } public static CardExpiryReminderEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static CardExpiryReminderEvent fromJson(JsonObject jsonObj) { CardExpiryReminderEvent obj = new CardExpiryReminderEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -140,16 +145,20 @@ public Card getCard() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - obj.customer = Customer.fromJson(__customerJson); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + obj.customer = Customer.fromJson(__customerObj); } - String __cardJson = JsonUtil.getObject(json, "card"); - if (__cardJson != null) { - obj.card = Card.fromJson(__cardJson); + JsonObject __cardObj = JsonUtil.getJsonObject(jsonObj, "card"); + if (__cardObj != null) { + obj.card = Card.fromJson(__cardObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/CardUpdatedEvent.java b/src/main/java/com/chargebee/v4/models/event/CardUpdatedEvent.java index de31a6dc..822d1a6d 100644 --- a/src/main/java/com/chargebee/v4/models/event/CardUpdatedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/CardUpdatedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.customer.Customer; @@ -57,25 +58,29 @@ public Content getContent() { } public static CardUpdatedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static CardUpdatedEvent fromJson(JsonObject jsonObj) { CardUpdatedEvent obj = new CardUpdatedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -140,16 +145,20 @@ public Card getCard() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - obj.customer = Customer.fromJson(__customerJson); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + obj.customer = Customer.fromJson(__customerObj); } - String __cardJson = JsonUtil.getObject(json, "card"); - if (__cardJson != null) { - obj.card = Card.fromJson(__cardJson); + JsonObject __cardObj = JsonUtil.getJsonObject(jsonObj, "card"); + if (__cardObj != null) { + obj.card = Card.fromJson(__cardObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/ContractTermCancelledEvent.java b/src/main/java/com/chargebee/v4/models/event/ContractTermCancelledEvent.java index e519b90c..cd6b29b1 100644 --- a/src/main/java/com/chargebee/v4/models/event/ContractTermCancelledEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/ContractTermCancelledEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.contractTerm.ContractTerm; @@ -55,25 +56,29 @@ public Content getContent() { } public static ContractTermCancelledEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static ContractTermCancelledEvent fromJson(JsonObject jsonObj) { ContractTermCancelledEvent obj = new ContractTermCancelledEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -133,11 +138,15 @@ public ContractTerm getContractTerm() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __contractTermJson = JsonUtil.getObject(json, "contract_term"); - if (__contractTermJson != null) { - obj.contractTerm = ContractTerm.fromJson(__contractTermJson); + JsonObject __contractTermObj = JsonUtil.getJsonObject(jsonObj, "contract_term"); + if (__contractTermObj != null) { + obj.contractTerm = ContractTerm.fromJson(__contractTermObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/ContractTermCompletedEvent.java b/src/main/java/com/chargebee/v4/models/event/ContractTermCompletedEvent.java index a48d31f5..b0af42ce 100644 --- a/src/main/java/com/chargebee/v4/models/event/ContractTermCompletedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/ContractTermCompletedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.contractTerm.ContractTerm; @@ -55,25 +56,29 @@ public Content getContent() { } public static ContractTermCompletedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static ContractTermCompletedEvent fromJson(JsonObject jsonObj) { ContractTermCompletedEvent obj = new ContractTermCompletedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -133,11 +138,15 @@ public ContractTerm getContractTerm() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __contractTermJson = JsonUtil.getObject(json, "contract_term"); - if (__contractTermJson != null) { - obj.contractTerm = ContractTerm.fromJson(__contractTermJson); + JsonObject __contractTermObj = JsonUtil.getJsonObject(jsonObj, "contract_term"); + if (__contractTermObj != null) { + obj.contractTerm = ContractTerm.fromJson(__contractTermObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/ContractTermCreatedEvent.java b/src/main/java/com/chargebee/v4/models/event/ContractTermCreatedEvent.java index 4f86d867..6ac489fd 100644 --- a/src/main/java/com/chargebee/v4/models/event/ContractTermCreatedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/ContractTermCreatedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.contractTerm.ContractTerm; @@ -55,25 +56,29 @@ public Content getContent() { } public static ContractTermCreatedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static ContractTermCreatedEvent fromJson(JsonObject jsonObj) { ContractTermCreatedEvent obj = new ContractTermCreatedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -133,11 +138,15 @@ public ContractTerm getContractTerm() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __contractTermJson = JsonUtil.getObject(json, "contract_term"); - if (__contractTermJson != null) { - obj.contractTerm = ContractTerm.fromJson(__contractTermJson); + JsonObject __contractTermObj = JsonUtil.getJsonObject(jsonObj, "contract_term"); + if (__contractTermObj != null) { + obj.contractTerm = ContractTerm.fromJson(__contractTermObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/ContractTermRenewedEvent.java b/src/main/java/com/chargebee/v4/models/event/ContractTermRenewedEvent.java index 63db75fb..4fec5645 100644 --- a/src/main/java/com/chargebee/v4/models/event/ContractTermRenewedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/ContractTermRenewedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.contractTerm.ContractTerm; @@ -55,25 +56,29 @@ public Content getContent() { } public static ContractTermRenewedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static ContractTermRenewedEvent fromJson(JsonObject jsonObj) { ContractTermRenewedEvent obj = new ContractTermRenewedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -133,11 +138,15 @@ public ContractTerm getContractTerm() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __contractTermJson = JsonUtil.getObject(json, "contract_term"); - if (__contractTermJson != null) { - obj.contractTerm = ContractTerm.fromJson(__contractTermJson); + JsonObject __contractTermObj = JsonUtil.getJsonObject(jsonObj, "contract_term"); + if (__contractTermObj != null) { + obj.contractTerm = ContractTerm.fromJson(__contractTermObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/ContractTermTerminatedEvent.java b/src/main/java/com/chargebee/v4/models/event/ContractTermTerminatedEvent.java index b03765da..9a33e716 100644 --- a/src/main/java/com/chargebee/v4/models/event/ContractTermTerminatedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/ContractTermTerminatedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.contractTerm.ContractTerm; @@ -55,25 +56,29 @@ public Content getContent() { } public static ContractTermTerminatedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static ContractTermTerminatedEvent fromJson(JsonObject jsonObj) { ContractTermTerminatedEvent obj = new ContractTermTerminatedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -133,11 +138,15 @@ public ContractTerm getContractTerm() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __contractTermJson = JsonUtil.getObject(json, "contract_term"); - if (__contractTermJson != null) { - obj.contractTerm = ContractTerm.fromJson(__contractTermJson); + JsonObject __contractTermObj = JsonUtil.getJsonObject(jsonObj, "contract_term"); + if (__contractTermObj != null) { + obj.contractTerm = ContractTerm.fromJson(__contractTermObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/CouponCodesAddedEvent.java b/src/main/java/com/chargebee/v4/models/event/CouponCodesAddedEvent.java index 601c9c31..449388b6 100644 --- a/src/main/java/com/chargebee/v4/models/event/CouponCodesAddedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/CouponCodesAddedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.couponSet.CouponSet; @@ -57,25 +58,29 @@ public Content getContent() { } public static CouponCodesAddedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static CouponCodesAddedEvent fromJson(JsonObject jsonObj) { CouponCodesAddedEvent obj = new CouponCodesAddedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -140,16 +145,20 @@ public CouponSet getCouponSet() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __couponJson = JsonUtil.getObject(json, "coupon"); - if (__couponJson != null) { - obj.coupon = Coupon.fromJson(__couponJson); + JsonObject __couponObj = JsonUtil.getJsonObject(jsonObj, "coupon"); + if (__couponObj != null) { + obj.coupon = Coupon.fromJson(__couponObj); } - String __couponSetJson = JsonUtil.getObject(json, "coupon_set"); - if (__couponSetJson != null) { - obj.couponSet = CouponSet.fromJson(__couponSetJson); + JsonObject __couponSetObj = JsonUtil.getJsonObject(jsonObj, "coupon_set"); + if (__couponSetObj != null) { + obj.couponSet = CouponSet.fromJson(__couponSetObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/CouponCodesDeletedEvent.java b/src/main/java/com/chargebee/v4/models/event/CouponCodesDeletedEvent.java index 8602f7e4..563bd526 100644 --- a/src/main/java/com/chargebee/v4/models/event/CouponCodesDeletedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/CouponCodesDeletedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.couponSet.CouponSet; @@ -59,25 +60,29 @@ public Content getContent() { } public static CouponCodesDeletedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static CouponCodesDeletedEvent fromJson(JsonObject jsonObj) { CouponCodesDeletedEvent obj = new CouponCodesDeletedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -147,21 +152,25 @@ public CouponCode getCouponCode() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __couponJson = JsonUtil.getObject(json, "coupon"); - if (__couponJson != null) { - obj.coupon = Coupon.fromJson(__couponJson); + JsonObject __couponObj = JsonUtil.getJsonObject(jsonObj, "coupon"); + if (__couponObj != null) { + obj.coupon = Coupon.fromJson(__couponObj); } - String __couponSetJson = JsonUtil.getObject(json, "coupon_set"); - if (__couponSetJson != null) { - obj.couponSet = CouponSet.fromJson(__couponSetJson); + JsonObject __couponSetObj = JsonUtil.getJsonObject(jsonObj, "coupon_set"); + if (__couponSetObj != null) { + obj.couponSet = CouponSet.fromJson(__couponSetObj); } - String __couponCodeJson = JsonUtil.getObject(json, "coupon_code"); - if (__couponCodeJson != null) { - obj.couponCode = CouponCode.fromJson(__couponCodeJson); + JsonObject __couponCodeObj = JsonUtil.getJsonObject(jsonObj, "coupon_code"); + if (__couponCodeObj != null) { + obj.couponCode = CouponCode.fromJson(__couponCodeObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/CouponCodesUpdatedEvent.java b/src/main/java/com/chargebee/v4/models/event/CouponCodesUpdatedEvent.java index 6467db48..bda18f28 100644 --- a/src/main/java/com/chargebee/v4/models/event/CouponCodesUpdatedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/CouponCodesUpdatedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.couponSet.CouponSet; @@ -57,25 +58,29 @@ public Content getContent() { } public static CouponCodesUpdatedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static CouponCodesUpdatedEvent fromJson(JsonObject jsonObj) { CouponCodesUpdatedEvent obj = new CouponCodesUpdatedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -140,16 +145,20 @@ public CouponSet getCouponSet() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __couponJson = JsonUtil.getObject(json, "coupon"); - if (__couponJson != null) { - obj.coupon = Coupon.fromJson(__couponJson); + JsonObject __couponObj = JsonUtil.getJsonObject(jsonObj, "coupon"); + if (__couponObj != null) { + obj.coupon = Coupon.fromJson(__couponObj); } - String __couponSetJson = JsonUtil.getObject(json, "coupon_set"); - if (__couponSetJson != null) { - obj.couponSet = CouponSet.fromJson(__couponSetJson); + JsonObject __couponSetObj = JsonUtil.getJsonObject(jsonObj, "coupon_set"); + if (__couponSetObj != null) { + obj.couponSet = CouponSet.fromJson(__couponSetObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/CouponCreatedEvent.java b/src/main/java/com/chargebee/v4/models/event/CouponCreatedEvent.java index f2d4ffd9..140d6970 100644 --- a/src/main/java/com/chargebee/v4/models/event/CouponCreatedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/CouponCreatedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.coupon.Coupon; @@ -55,25 +56,29 @@ public Content getContent() { } public static CouponCreatedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static CouponCreatedEvent fromJson(JsonObject jsonObj) { CouponCreatedEvent obj = new CouponCreatedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -133,11 +138,15 @@ public Coupon getCoupon() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __couponJson = JsonUtil.getObject(json, "coupon"); - if (__couponJson != null) { - obj.coupon = Coupon.fromJson(__couponJson); + JsonObject __couponObj = JsonUtil.getJsonObject(jsonObj, "coupon"); + if (__couponObj != null) { + obj.coupon = Coupon.fromJson(__couponObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/CouponDeletedEvent.java b/src/main/java/com/chargebee/v4/models/event/CouponDeletedEvent.java index 5900f84e..218c0add 100644 --- a/src/main/java/com/chargebee/v4/models/event/CouponDeletedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/CouponDeletedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.coupon.Coupon; @@ -55,25 +56,29 @@ public Content getContent() { } public static CouponDeletedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static CouponDeletedEvent fromJson(JsonObject jsonObj) { CouponDeletedEvent obj = new CouponDeletedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -133,11 +138,15 @@ public Coupon getCoupon() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __couponJson = JsonUtil.getObject(json, "coupon"); - if (__couponJson != null) { - obj.coupon = Coupon.fromJson(__couponJson); + JsonObject __couponObj = JsonUtil.getJsonObject(jsonObj, "coupon"); + if (__couponObj != null) { + obj.coupon = Coupon.fromJson(__couponObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/CouponSetCreatedEvent.java b/src/main/java/com/chargebee/v4/models/event/CouponSetCreatedEvent.java index 8c36a69d..0a4914d9 100644 --- a/src/main/java/com/chargebee/v4/models/event/CouponSetCreatedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/CouponSetCreatedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.couponSet.CouponSet; @@ -57,25 +58,29 @@ public Content getContent() { } public static CouponSetCreatedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static CouponSetCreatedEvent fromJson(JsonObject jsonObj) { CouponSetCreatedEvent obj = new CouponSetCreatedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -140,16 +145,20 @@ public CouponSet getCouponSet() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __couponJson = JsonUtil.getObject(json, "coupon"); - if (__couponJson != null) { - obj.coupon = Coupon.fromJson(__couponJson); + JsonObject __couponObj = JsonUtil.getJsonObject(jsonObj, "coupon"); + if (__couponObj != null) { + obj.coupon = Coupon.fromJson(__couponObj); } - String __couponSetJson = JsonUtil.getObject(json, "coupon_set"); - if (__couponSetJson != null) { - obj.couponSet = CouponSet.fromJson(__couponSetJson); + JsonObject __couponSetObj = JsonUtil.getJsonObject(jsonObj, "coupon_set"); + if (__couponSetObj != null) { + obj.couponSet = CouponSet.fromJson(__couponSetObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/CouponSetDeletedEvent.java b/src/main/java/com/chargebee/v4/models/event/CouponSetDeletedEvent.java index 8fc7ad3b..a01315c9 100644 --- a/src/main/java/com/chargebee/v4/models/event/CouponSetDeletedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/CouponSetDeletedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.couponSet.CouponSet; @@ -57,25 +58,29 @@ public Content getContent() { } public static CouponSetDeletedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static CouponSetDeletedEvent fromJson(JsonObject jsonObj) { CouponSetDeletedEvent obj = new CouponSetDeletedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -140,16 +145,20 @@ public CouponSet getCouponSet() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __couponJson = JsonUtil.getObject(json, "coupon"); - if (__couponJson != null) { - obj.coupon = Coupon.fromJson(__couponJson); + JsonObject __couponObj = JsonUtil.getJsonObject(jsonObj, "coupon"); + if (__couponObj != null) { + obj.coupon = Coupon.fromJson(__couponObj); } - String __couponSetJson = JsonUtil.getObject(json, "coupon_set"); - if (__couponSetJson != null) { - obj.couponSet = CouponSet.fromJson(__couponSetJson); + JsonObject __couponSetObj = JsonUtil.getJsonObject(jsonObj, "coupon_set"); + if (__couponSetObj != null) { + obj.couponSet = CouponSet.fromJson(__couponSetObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/CouponSetUpdatedEvent.java b/src/main/java/com/chargebee/v4/models/event/CouponSetUpdatedEvent.java index ed55d565..5521a650 100644 --- a/src/main/java/com/chargebee/v4/models/event/CouponSetUpdatedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/CouponSetUpdatedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.couponSet.CouponSet; @@ -57,25 +58,29 @@ public Content getContent() { } public static CouponSetUpdatedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static CouponSetUpdatedEvent fromJson(JsonObject jsonObj) { CouponSetUpdatedEvent obj = new CouponSetUpdatedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -140,16 +145,20 @@ public CouponSet getCouponSet() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __couponJson = JsonUtil.getObject(json, "coupon"); - if (__couponJson != null) { - obj.coupon = Coupon.fromJson(__couponJson); + JsonObject __couponObj = JsonUtil.getJsonObject(jsonObj, "coupon"); + if (__couponObj != null) { + obj.coupon = Coupon.fromJson(__couponObj); } - String __couponSetJson = JsonUtil.getObject(json, "coupon_set"); - if (__couponSetJson != null) { - obj.couponSet = CouponSet.fromJson(__couponSetJson); + JsonObject __couponSetObj = JsonUtil.getJsonObject(jsonObj, "coupon_set"); + if (__couponSetObj != null) { + obj.couponSet = CouponSet.fromJson(__couponSetObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/CouponUpdatedEvent.java b/src/main/java/com/chargebee/v4/models/event/CouponUpdatedEvent.java index ab19852f..42221da3 100644 --- a/src/main/java/com/chargebee/v4/models/event/CouponUpdatedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/CouponUpdatedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.coupon.Coupon; @@ -55,25 +56,29 @@ public Content getContent() { } public static CouponUpdatedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static CouponUpdatedEvent fromJson(JsonObject jsonObj) { CouponUpdatedEvent obj = new CouponUpdatedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -133,11 +138,15 @@ public Coupon getCoupon() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __couponJson = JsonUtil.getObject(json, "coupon"); - if (__couponJson != null) { - obj.coupon = Coupon.fromJson(__couponJson); + JsonObject __couponObj = JsonUtil.getJsonObject(jsonObj, "coupon"); + if (__couponObj != null) { + obj.coupon = Coupon.fromJson(__couponObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/CreditNoteCreatedEvent.java b/src/main/java/com/chargebee/v4/models/event/CreditNoteCreatedEvent.java index 3b93d875..62c96571 100644 --- a/src/main/java/com/chargebee/v4/models/event/CreditNoteCreatedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/CreditNoteCreatedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.creditNote.CreditNote; @@ -55,25 +56,29 @@ public Content getContent() { } public static CreditNoteCreatedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static CreditNoteCreatedEvent fromJson(JsonObject jsonObj) { CreditNoteCreatedEvent obj = new CreditNoteCreatedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -133,11 +138,15 @@ public CreditNote getCreditNote() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __creditNoteJson = JsonUtil.getObject(json, "credit_note"); - if (__creditNoteJson != null) { - obj.creditNote = CreditNote.fromJson(__creditNoteJson); + JsonObject __creditNoteObj = JsonUtil.getJsonObject(jsonObj, "credit_note"); + if (__creditNoteObj != null) { + obj.creditNote = CreditNote.fromJson(__creditNoteObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/CreditNoteCreatedWithBackdatingEvent.java b/src/main/java/com/chargebee/v4/models/event/CreditNoteCreatedWithBackdatingEvent.java index e9692710..dae8a78b 100644 --- a/src/main/java/com/chargebee/v4/models/event/CreditNoteCreatedWithBackdatingEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/CreditNoteCreatedWithBackdatingEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.creditNote.CreditNote; @@ -55,25 +56,29 @@ public Content getContent() { } public static CreditNoteCreatedWithBackdatingEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static CreditNoteCreatedWithBackdatingEvent fromJson(JsonObject jsonObj) { CreditNoteCreatedWithBackdatingEvent obj = new CreditNoteCreatedWithBackdatingEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -133,11 +138,15 @@ public CreditNote getCreditNote() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __creditNoteJson = JsonUtil.getObject(json, "credit_note"); - if (__creditNoteJson != null) { - obj.creditNote = CreditNote.fromJson(__creditNoteJson); + JsonObject __creditNoteObj = JsonUtil.getJsonObject(jsonObj, "credit_note"); + if (__creditNoteObj != null) { + obj.creditNote = CreditNote.fromJson(__creditNoteObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/CreditNoteDeletedEvent.java b/src/main/java/com/chargebee/v4/models/event/CreditNoteDeletedEvent.java index 5d91b765..83100460 100644 --- a/src/main/java/com/chargebee/v4/models/event/CreditNoteDeletedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/CreditNoteDeletedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.creditNote.CreditNote; @@ -55,25 +56,29 @@ public Content getContent() { } public static CreditNoteDeletedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static CreditNoteDeletedEvent fromJson(JsonObject jsonObj) { CreditNoteDeletedEvent obj = new CreditNoteDeletedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -133,11 +138,15 @@ public CreditNote getCreditNote() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __creditNoteJson = JsonUtil.getObject(json, "credit_note"); - if (__creditNoteJson != null) { - obj.creditNote = CreditNote.fromJson(__creditNoteJson); + JsonObject __creditNoteObj = JsonUtil.getJsonObject(jsonObj, "credit_note"); + if (__creditNoteObj != null) { + obj.creditNote = CreditNote.fromJson(__creditNoteObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/CreditNoteUpdatedEvent.java b/src/main/java/com/chargebee/v4/models/event/CreditNoteUpdatedEvent.java index b6f84ef4..7f139803 100644 --- a/src/main/java/com/chargebee/v4/models/event/CreditNoteUpdatedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/CreditNoteUpdatedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.creditNote.CreditNote; @@ -55,25 +56,29 @@ public Content getContent() { } public static CreditNoteUpdatedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static CreditNoteUpdatedEvent fromJson(JsonObject jsonObj) { CreditNoteUpdatedEvent obj = new CreditNoteUpdatedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -133,11 +138,15 @@ public CreditNote getCreditNote() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __creditNoteJson = JsonUtil.getObject(json, "credit_note"); - if (__creditNoteJson != null) { - obj.creditNote = CreditNote.fromJson(__creditNoteJson); + JsonObject __creditNoteObj = JsonUtil.getJsonObject(jsonObj, "credit_note"); + if (__creditNoteObj != null) { + obj.creditNote = CreditNote.fromJson(__creditNoteObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/CustomerBusinessEntityChangedEvent.java b/src/main/java/com/chargebee/v4/models/event/CustomerBusinessEntityChangedEvent.java index f2bd3b19..a0fb726c 100644 --- a/src/main/java/com/chargebee/v4/models/event/CustomerBusinessEntityChangedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/CustomerBusinessEntityChangedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.customer.Customer; @@ -57,25 +58,29 @@ public Content getContent() { } public static CustomerBusinessEntityChangedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static CustomerBusinessEntityChangedEvent fromJson(JsonObject jsonObj) { CustomerBusinessEntityChangedEvent obj = new CustomerBusinessEntityChangedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -140,16 +145,21 @@ public Customer getCustomer() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __businessEntityTransferJson = JsonUtil.getObject(json, "business_entity_transfer"); - if (__businessEntityTransferJson != null) { - obj.businessEntityTransfer = BusinessEntityTransfer.fromJson(__businessEntityTransferJson); + JsonObject __businessEntityTransferObj = + JsonUtil.getJsonObject(jsonObj, "business_entity_transfer"); + if (__businessEntityTransferObj != null) { + obj.businessEntityTransfer = BusinessEntityTransfer.fromJson(__businessEntityTransferObj); } - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - obj.customer = Customer.fromJson(__customerJson); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + obj.customer = Customer.fromJson(__customerObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/CustomerChangedEvent.java b/src/main/java/com/chargebee/v4/models/event/CustomerChangedEvent.java index 6621dc04..b0569c7a 100644 --- a/src/main/java/com/chargebee/v4/models/event/CustomerChangedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/CustomerChangedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.customer.Customer; @@ -57,25 +58,29 @@ public Content getContent() { } public static CustomerChangedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static CustomerChangedEvent fromJson(JsonObject jsonObj) { CustomerChangedEvent obj = new CustomerChangedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -140,16 +145,20 @@ public Card getCard() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - obj.customer = Customer.fromJson(__customerJson); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + obj.customer = Customer.fromJson(__customerObj); } - String __cardJson = JsonUtil.getObject(json, "card"); - if (__cardJson != null) { - obj.card = Card.fromJson(__cardJson); + JsonObject __cardObj = JsonUtil.getJsonObject(jsonObj, "card"); + if (__cardObj != null) { + obj.card = Card.fromJson(__cardObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/CustomerCreatedEvent.java b/src/main/java/com/chargebee/v4/models/event/CustomerCreatedEvent.java index bca60c8c..be02658e 100644 --- a/src/main/java/com/chargebee/v4/models/event/CustomerCreatedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/CustomerCreatedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.customer.Customer; @@ -57,25 +58,29 @@ public Content getContent() { } public static CustomerCreatedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static CustomerCreatedEvent fromJson(JsonObject jsonObj) { CustomerCreatedEvent obj = new CustomerCreatedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -140,16 +145,20 @@ public Card getCard() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - obj.customer = Customer.fromJson(__customerJson); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + obj.customer = Customer.fromJson(__customerObj); } - String __cardJson = JsonUtil.getObject(json, "card"); - if (__cardJson != null) { - obj.card = Card.fromJson(__cardJson); + JsonObject __cardObj = JsonUtil.getJsonObject(jsonObj, "card"); + if (__cardObj != null) { + obj.card = Card.fromJson(__cardObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/CustomerDeletedEvent.java b/src/main/java/com/chargebee/v4/models/event/CustomerDeletedEvent.java index 5c688f08..0712924b 100644 --- a/src/main/java/com/chargebee/v4/models/event/CustomerDeletedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/CustomerDeletedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import java.util.List; import com.chargebee.v4.models.customer.Customer; @@ -60,25 +61,29 @@ public Content getContent() { } public static CustomerDeletedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static CustomerDeletedEvent fromJson(JsonObject jsonObj) { CustomerDeletedEvent obj = new CustomerDeletedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -148,22 +153,25 @@ public List getSubscriptions() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - obj.customer = Customer.fromJson(__customerJson); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + obj.customer = Customer.fromJson(__customerObj); } - String __cardJson = JsonUtil.getObject(json, "card"); - if (__cardJson != null) { - obj.card = Card.fromJson(__cardJson); + JsonObject __cardObj = JsonUtil.getJsonObject(jsonObj, "card"); + if (__cardObj != null) { + obj.card = Card.fromJson(__cardObj); } obj.subscriptions = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "subscriptions")).stream() - .map(Subscription::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "subscriptions"), Subscription::fromJson); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/event/CustomerEntitlementsUpdatedEvent.java b/src/main/java/com/chargebee/v4/models/event/CustomerEntitlementsUpdatedEvent.java index a6eb18b8..783f8110 100644 --- a/src/main/java/com/chargebee/v4/models/event/CustomerEntitlementsUpdatedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/CustomerEntitlementsUpdatedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.impactedCustomer.ImpactedCustomer; @@ -55,25 +56,29 @@ public Content getContent() { } public static CustomerEntitlementsUpdatedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static CustomerEntitlementsUpdatedEvent fromJson(JsonObject jsonObj) { CustomerEntitlementsUpdatedEvent obj = new CustomerEntitlementsUpdatedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -133,11 +138,15 @@ public ImpactedCustomer getImpactedCustomer() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __impactedCustomerJson = JsonUtil.getObject(json, "impacted_customer"); - if (__impactedCustomerJson != null) { - obj.impactedCustomer = ImpactedCustomer.fromJson(__impactedCustomerJson); + JsonObject __impactedCustomerObj = JsonUtil.getJsonObject(jsonObj, "impacted_customer"); + if (__impactedCustomerObj != null) { + obj.impactedCustomer = ImpactedCustomer.fromJson(__impactedCustomerObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/CustomerMovedInEvent.java b/src/main/java/com/chargebee/v4/models/event/CustomerMovedInEvent.java index 8d12fa7b..4df221bf 100644 --- a/src/main/java/com/chargebee/v4/models/event/CustomerMovedInEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/CustomerMovedInEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.customer.Customer; @@ -57,25 +58,29 @@ public Content getContent() { } public static CustomerMovedInEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static CustomerMovedInEvent fromJson(JsonObject jsonObj) { CustomerMovedInEvent obj = new CustomerMovedInEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -140,16 +145,20 @@ public Card getCard() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - obj.customer = Customer.fromJson(__customerJson); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + obj.customer = Customer.fromJson(__customerObj); } - String __cardJson = JsonUtil.getObject(json, "card"); - if (__cardJson != null) { - obj.card = Card.fromJson(__cardJson); + JsonObject __cardObj = JsonUtil.getJsonObject(jsonObj, "card"); + if (__cardObj != null) { + obj.card = Card.fromJson(__cardObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/CustomerMovedOutEvent.java b/src/main/java/com/chargebee/v4/models/event/CustomerMovedOutEvent.java index b3e03f53..e0e2d2c6 100644 --- a/src/main/java/com/chargebee/v4/models/event/CustomerMovedOutEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/CustomerMovedOutEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.customer.Customer; @@ -57,25 +58,29 @@ public Content getContent() { } public static CustomerMovedOutEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static CustomerMovedOutEvent fromJson(JsonObject jsonObj) { CustomerMovedOutEvent obj = new CustomerMovedOutEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -140,16 +145,20 @@ public Card getCard() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - obj.customer = Customer.fromJson(__customerJson); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + obj.customer = Customer.fromJson(__customerObj); } - String __cardJson = JsonUtil.getObject(json, "card"); - if (__cardJson != null) { - obj.card = Card.fromJson(__cardJson); + JsonObject __cardObj = JsonUtil.getJsonObject(jsonObj, "card"); + if (__cardObj != null) { + obj.card = Card.fromJson(__cardObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/DifferentialPriceCreatedEvent.java b/src/main/java/com/chargebee/v4/models/event/DifferentialPriceCreatedEvent.java index 206ef24a..503c6ea3 100644 --- a/src/main/java/com/chargebee/v4/models/event/DifferentialPriceCreatedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/DifferentialPriceCreatedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.differentialPrice.DifferentialPrice; @@ -55,25 +56,29 @@ public Content getContent() { } public static DifferentialPriceCreatedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static DifferentialPriceCreatedEvent fromJson(JsonObject jsonObj) { DifferentialPriceCreatedEvent obj = new DifferentialPriceCreatedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -133,11 +138,15 @@ public DifferentialPrice getDifferentialPrice() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __differentialPriceJson = JsonUtil.getObject(json, "differential_price"); - if (__differentialPriceJson != null) { - obj.differentialPrice = DifferentialPrice.fromJson(__differentialPriceJson); + JsonObject __differentialPriceObj = JsonUtil.getJsonObject(jsonObj, "differential_price"); + if (__differentialPriceObj != null) { + obj.differentialPrice = DifferentialPrice.fromJson(__differentialPriceObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/DifferentialPriceDeletedEvent.java b/src/main/java/com/chargebee/v4/models/event/DifferentialPriceDeletedEvent.java index c1b5d874..f348c66a 100644 --- a/src/main/java/com/chargebee/v4/models/event/DifferentialPriceDeletedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/DifferentialPriceDeletedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.differentialPrice.DifferentialPrice; @@ -55,25 +56,29 @@ public Content getContent() { } public static DifferentialPriceDeletedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static DifferentialPriceDeletedEvent fromJson(JsonObject jsonObj) { DifferentialPriceDeletedEvent obj = new DifferentialPriceDeletedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -133,11 +138,15 @@ public DifferentialPrice getDifferentialPrice() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __differentialPriceJson = JsonUtil.getObject(json, "differential_price"); - if (__differentialPriceJson != null) { - obj.differentialPrice = DifferentialPrice.fromJson(__differentialPriceJson); + JsonObject __differentialPriceObj = JsonUtil.getJsonObject(jsonObj, "differential_price"); + if (__differentialPriceObj != null) { + obj.differentialPrice = DifferentialPrice.fromJson(__differentialPriceObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/DifferentialPriceUpdatedEvent.java b/src/main/java/com/chargebee/v4/models/event/DifferentialPriceUpdatedEvent.java index a2bd08e7..f317b27e 100644 --- a/src/main/java/com/chargebee/v4/models/event/DifferentialPriceUpdatedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/DifferentialPriceUpdatedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.differentialPrice.DifferentialPrice; @@ -55,25 +56,29 @@ public Content getContent() { } public static DifferentialPriceUpdatedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static DifferentialPriceUpdatedEvent fromJson(JsonObject jsonObj) { DifferentialPriceUpdatedEvent obj = new DifferentialPriceUpdatedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -133,11 +138,15 @@ public DifferentialPrice getDifferentialPrice() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __differentialPriceJson = JsonUtil.getObject(json, "differential_price"); - if (__differentialPriceJson != null) { - obj.differentialPrice = DifferentialPrice.fromJson(__differentialPriceJson); + JsonObject __differentialPriceObj = JsonUtil.getJsonObject(jsonObj, "differential_price"); + if (__differentialPriceObj != null) { + obj.differentialPrice = DifferentialPrice.fromJson(__differentialPriceObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/DunningUpdatedEvent.java b/src/main/java/com/chargebee/v4/models/event/DunningUpdatedEvent.java index 031a64e8..97f5b8ee 100644 --- a/src/main/java/com/chargebee/v4/models/event/DunningUpdatedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/DunningUpdatedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.invoice.Invoice; @@ -55,25 +56,29 @@ public Content getContent() { } public static DunningUpdatedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static DunningUpdatedEvent fromJson(JsonObject jsonObj) { DunningUpdatedEvent obj = new DunningUpdatedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -133,11 +138,15 @@ public Invoice getInvoice() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __invoiceJson = JsonUtil.getObject(json, "invoice"); - if (__invoiceJson != null) { - obj.invoice = Invoice.fromJson(__invoiceJson); + JsonObject __invoiceObj = JsonUtil.getJsonObject(jsonObj, "invoice"); + if (__invoiceObj != null) { + obj.invoice = Invoice.fromJson(__invoiceObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/EntitlementOverridesAutoRemovedEvent.java b/src/main/java/com/chargebee/v4/models/event/EntitlementOverridesAutoRemovedEvent.java index a4b32d7d..71b0fbfa 100644 --- a/src/main/java/com/chargebee/v4/models/event/EntitlementOverridesAutoRemovedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/EntitlementOverridesAutoRemovedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.impactedItem.ImpactedItem; @@ -61,25 +62,29 @@ public Content getContent() { } public static EntitlementOverridesAutoRemovedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static EntitlementOverridesAutoRemovedEvent fromJson(JsonObject jsonObj) { EntitlementOverridesAutoRemovedEvent obj = new EntitlementOverridesAutoRemovedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -154,26 +159,31 @@ public ImpactedSubscription getImpactedSubscription() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __featureJson = JsonUtil.getObject(json, "feature"); - if (__featureJson != null) { - obj.feature = Feature.fromJson(__featureJson); + JsonObject __featureObj = JsonUtil.getJsonObject(jsonObj, "feature"); + if (__featureObj != null) { + obj.feature = Feature.fromJson(__featureObj); } - String __metadataJson = JsonUtil.getObject(json, "metadata"); - if (__metadataJson != null) { - obj.metadata = Metadata.fromJson(__metadataJson); + JsonObject __metadataObj = JsonUtil.getJsonObject(jsonObj, "metadata"); + if (__metadataObj != null) { + obj.metadata = Metadata.fromJson(__metadataObj); } - String __impactedItemJson = JsonUtil.getObject(json, "impacted_item"); - if (__impactedItemJson != null) { - obj.impactedItem = ImpactedItem.fromJson(__impactedItemJson); + JsonObject __impactedItemObj = JsonUtil.getJsonObject(jsonObj, "impacted_item"); + if (__impactedItemObj != null) { + obj.impactedItem = ImpactedItem.fromJson(__impactedItemObj); } - String __impactedSubscriptionJson = JsonUtil.getObject(json, "impacted_subscription"); - if (__impactedSubscriptionJson != null) { - obj.impactedSubscription = ImpactedSubscription.fromJson(__impactedSubscriptionJson); + JsonObject __impactedSubscriptionObj = + JsonUtil.getJsonObject(jsonObj, "impacted_subscription"); + if (__impactedSubscriptionObj != null) { + obj.impactedSubscription = ImpactedSubscription.fromJson(__impactedSubscriptionObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/EntitlementOverridesRemovedEvent.java b/src/main/java/com/chargebee/v4/models/event/EntitlementOverridesRemovedEvent.java index a7e5e98c..4f0a2002 100644 --- a/src/main/java/com/chargebee/v4/models/event/EntitlementOverridesRemovedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/EntitlementOverridesRemovedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.metadata.Metadata; @@ -57,25 +58,29 @@ public Content getContent() { } public static EntitlementOverridesRemovedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static EntitlementOverridesRemovedEvent fromJson(JsonObject jsonObj) { EntitlementOverridesRemovedEvent obj = new EntitlementOverridesRemovedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -140,16 +145,21 @@ public Metadata getMetadata() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __impactedSubscriptionJson = JsonUtil.getObject(json, "impacted_subscription"); - if (__impactedSubscriptionJson != null) { - obj.impactedSubscription = ImpactedSubscription.fromJson(__impactedSubscriptionJson); + JsonObject __impactedSubscriptionObj = + JsonUtil.getJsonObject(jsonObj, "impacted_subscription"); + if (__impactedSubscriptionObj != null) { + obj.impactedSubscription = ImpactedSubscription.fromJson(__impactedSubscriptionObj); } - String __metadataJson = JsonUtil.getObject(json, "metadata"); - if (__metadataJson != null) { - obj.metadata = Metadata.fromJson(__metadataJson); + JsonObject __metadataObj = JsonUtil.getJsonObject(jsonObj, "metadata"); + if (__metadataObj != null) { + obj.metadata = Metadata.fromJson(__metadataObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/EntitlementOverridesUpdatedEvent.java b/src/main/java/com/chargebee/v4/models/event/EntitlementOverridesUpdatedEvent.java index 855d39dc..3499ddc6 100644 --- a/src/main/java/com/chargebee/v4/models/event/EntitlementOverridesUpdatedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/EntitlementOverridesUpdatedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.metadata.Metadata; @@ -57,25 +58,29 @@ public Content getContent() { } public static EntitlementOverridesUpdatedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static EntitlementOverridesUpdatedEvent fromJson(JsonObject jsonObj) { EntitlementOverridesUpdatedEvent obj = new EntitlementOverridesUpdatedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -140,16 +145,21 @@ public Metadata getMetadata() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __impactedSubscriptionJson = JsonUtil.getObject(json, "impacted_subscription"); - if (__impactedSubscriptionJson != null) { - obj.impactedSubscription = ImpactedSubscription.fromJson(__impactedSubscriptionJson); + JsonObject __impactedSubscriptionObj = + JsonUtil.getJsonObject(jsonObj, "impacted_subscription"); + if (__impactedSubscriptionObj != null) { + obj.impactedSubscription = ImpactedSubscription.fromJson(__impactedSubscriptionObj); } - String __metadataJson = JsonUtil.getObject(json, "metadata"); - if (__metadataJson != null) { - obj.metadata = Metadata.fromJson(__metadataJson); + JsonObject __metadataObj = JsonUtil.getJsonObject(jsonObj, "metadata"); + if (__metadataObj != null) { + obj.metadata = Metadata.fromJson(__metadataObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/Event.java b/src/main/java/com/chargebee/v4/models/event/Event.java index f1ff07db..0ed5c7d1 100644 --- a/src/main/java/com/chargebee/v4/models/event/Event.java +++ b/src/main/java/com/chargebee/v4/models/event/Event.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import java.sql.Timestamp; import java.util.List; @@ -668,36 +669,38 @@ public static ApiVersion fromString(String value) { } public static Event fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Event fromJson(JsonObject jsonObj) { Event obj = new Event(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getTimestamp(json, "occurred_at"); + obj.occurredAt = JsonUtil.getTimestamp(jsonObj, "occurred_at"); - obj.source = Source.fromString(JsonUtil.getString(json, "source")); + obj.source = Source.fromString(JsonUtil.getString(jsonObj, "source")); - obj.user = JsonUtil.getString(json, "user"); + obj.user = JsonUtil.getString(jsonObj, "user"); - obj.webhookStatus = WebhookStatus.fromString(JsonUtil.getString(json, "webhook_status")); + obj.webhookStatus = WebhookStatus.fromString(JsonUtil.getString(jsonObj, "webhook_status")); - obj.webhookFailureReason = JsonUtil.getString(json, "webhook_failure_reason"); + obj.webhookFailureReason = JsonUtil.getString(jsonObj, "webhook_failure_reason"); - obj.eventType = EventType.fromString(JsonUtil.getString(json, "event_type")); + obj.eventType = EventType.fromString(JsonUtil.getString(jsonObj, "event_type")); - obj.apiVersion = ApiVersion.fromString(JsonUtil.getString(json, "api_version")); + obj.apiVersion = ApiVersion.fromString(JsonUtil.getString(jsonObj, "api_version")); - String __contentJson = JsonUtil.getObject(json, "content"); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); obj.content = - __contentJson != null - ? JsonUtil.parseJsonObjectToMap(__contentJson) + __contentObj != null + ? JsonUtil.parseJsonObjectToMap(__contentObj) : new java.util.HashMap<>(); - obj.originUser = JsonUtil.getString(json, "origin_user"); + obj.originUser = JsonUtil.getString(jsonObj, "origin_user"); obj.webhooks = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "webhooks")).stream() - .map(Webhooks::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "webhooks"), Webhooks::fromJson); return obj; } @@ -820,11 +823,15 @@ public static WebhookStatus fromString(String value) { } public static Webhooks fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Webhooks fromJson(JsonObject jsonObj) { Webhooks obj = new Webhooks(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.webhookStatus = WebhookStatus.fromString(JsonUtil.getString(json, "webhook_status")); + obj.webhookStatus = WebhookStatus.fromString(JsonUtil.getString(jsonObj, "webhook_status")); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/event/FeatureActivatedEvent.java b/src/main/java/com/chargebee/v4/models/event/FeatureActivatedEvent.java index cf1a3efa..f196cca8 100644 --- a/src/main/java/com/chargebee/v4/models/event/FeatureActivatedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/FeatureActivatedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.impactedItem.ImpactedItem; @@ -61,25 +62,29 @@ public Content getContent() { } public static FeatureActivatedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static FeatureActivatedEvent fromJson(JsonObject jsonObj) { FeatureActivatedEvent obj = new FeatureActivatedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -154,26 +159,31 @@ public ImpactedSubscription getImpactedSubscription() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __featureJson = JsonUtil.getObject(json, "feature"); - if (__featureJson != null) { - obj.feature = Feature.fromJson(__featureJson); + JsonObject __featureObj = JsonUtil.getJsonObject(jsonObj, "feature"); + if (__featureObj != null) { + obj.feature = Feature.fromJson(__featureObj); } - String __metadataJson = JsonUtil.getObject(json, "metadata"); - if (__metadataJson != null) { - obj.metadata = Metadata.fromJson(__metadataJson); + JsonObject __metadataObj = JsonUtil.getJsonObject(jsonObj, "metadata"); + if (__metadataObj != null) { + obj.metadata = Metadata.fromJson(__metadataObj); } - String __impactedItemJson = JsonUtil.getObject(json, "impacted_item"); - if (__impactedItemJson != null) { - obj.impactedItem = ImpactedItem.fromJson(__impactedItemJson); + JsonObject __impactedItemObj = JsonUtil.getJsonObject(jsonObj, "impacted_item"); + if (__impactedItemObj != null) { + obj.impactedItem = ImpactedItem.fromJson(__impactedItemObj); } - String __impactedSubscriptionJson = JsonUtil.getObject(json, "impacted_subscription"); - if (__impactedSubscriptionJson != null) { - obj.impactedSubscription = ImpactedSubscription.fromJson(__impactedSubscriptionJson); + JsonObject __impactedSubscriptionObj = + JsonUtil.getJsonObject(jsonObj, "impacted_subscription"); + if (__impactedSubscriptionObj != null) { + obj.impactedSubscription = ImpactedSubscription.fromJson(__impactedSubscriptionObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/FeatureArchivedEvent.java b/src/main/java/com/chargebee/v4/models/event/FeatureArchivedEvent.java index 51fb3120..df90b760 100644 --- a/src/main/java/com/chargebee/v4/models/event/FeatureArchivedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/FeatureArchivedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.metadata.Metadata; @@ -57,25 +58,29 @@ public Content getContent() { } public static FeatureArchivedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static FeatureArchivedEvent fromJson(JsonObject jsonObj) { FeatureArchivedEvent obj = new FeatureArchivedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -140,16 +145,20 @@ public Metadata getMetadata() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __featureJson = JsonUtil.getObject(json, "feature"); - if (__featureJson != null) { - obj.feature = Feature.fromJson(__featureJson); + JsonObject __featureObj = JsonUtil.getJsonObject(jsonObj, "feature"); + if (__featureObj != null) { + obj.feature = Feature.fromJson(__featureObj); } - String __metadataJson = JsonUtil.getObject(json, "metadata"); - if (__metadataJson != null) { - obj.metadata = Metadata.fromJson(__metadataJson); + JsonObject __metadataObj = JsonUtil.getJsonObject(jsonObj, "metadata"); + if (__metadataObj != null) { + obj.metadata = Metadata.fromJson(__metadataObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/FeatureCreatedEvent.java b/src/main/java/com/chargebee/v4/models/event/FeatureCreatedEvent.java index 6034dcc0..e5458bea 100644 --- a/src/main/java/com/chargebee/v4/models/event/FeatureCreatedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/FeatureCreatedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.impactedItem.ImpactedItem; @@ -61,25 +62,29 @@ public Content getContent() { } public static FeatureCreatedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static FeatureCreatedEvent fromJson(JsonObject jsonObj) { FeatureCreatedEvent obj = new FeatureCreatedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -154,26 +159,31 @@ public ImpactedSubscription getImpactedSubscription() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __featureJson = JsonUtil.getObject(json, "feature"); - if (__featureJson != null) { - obj.feature = Feature.fromJson(__featureJson); + JsonObject __featureObj = JsonUtil.getJsonObject(jsonObj, "feature"); + if (__featureObj != null) { + obj.feature = Feature.fromJson(__featureObj); } - String __metadataJson = JsonUtil.getObject(json, "metadata"); - if (__metadataJson != null) { - obj.metadata = Metadata.fromJson(__metadataJson); + JsonObject __metadataObj = JsonUtil.getJsonObject(jsonObj, "metadata"); + if (__metadataObj != null) { + obj.metadata = Metadata.fromJson(__metadataObj); } - String __impactedItemJson = JsonUtil.getObject(json, "impacted_item"); - if (__impactedItemJson != null) { - obj.impactedItem = ImpactedItem.fromJson(__impactedItemJson); + JsonObject __impactedItemObj = JsonUtil.getJsonObject(jsonObj, "impacted_item"); + if (__impactedItemObj != null) { + obj.impactedItem = ImpactedItem.fromJson(__impactedItemObj); } - String __impactedSubscriptionJson = JsonUtil.getObject(json, "impacted_subscription"); - if (__impactedSubscriptionJson != null) { - obj.impactedSubscription = ImpactedSubscription.fromJson(__impactedSubscriptionJson); + JsonObject __impactedSubscriptionObj = + JsonUtil.getJsonObject(jsonObj, "impacted_subscription"); + if (__impactedSubscriptionObj != null) { + obj.impactedSubscription = ImpactedSubscription.fromJson(__impactedSubscriptionObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/FeatureDeletedEvent.java b/src/main/java/com/chargebee/v4/models/event/FeatureDeletedEvent.java index c78691bd..adfd846f 100644 --- a/src/main/java/com/chargebee/v4/models/event/FeatureDeletedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/FeatureDeletedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.impactedItem.ImpactedItem; @@ -61,25 +62,29 @@ public Content getContent() { } public static FeatureDeletedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static FeatureDeletedEvent fromJson(JsonObject jsonObj) { FeatureDeletedEvent obj = new FeatureDeletedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -154,26 +159,31 @@ public ImpactedSubscription getImpactedSubscription() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __featureJson = JsonUtil.getObject(json, "feature"); - if (__featureJson != null) { - obj.feature = Feature.fromJson(__featureJson); + JsonObject __featureObj = JsonUtil.getJsonObject(jsonObj, "feature"); + if (__featureObj != null) { + obj.feature = Feature.fromJson(__featureObj); } - String __metadataJson = JsonUtil.getObject(json, "metadata"); - if (__metadataJson != null) { - obj.metadata = Metadata.fromJson(__metadataJson); + JsonObject __metadataObj = JsonUtil.getJsonObject(jsonObj, "metadata"); + if (__metadataObj != null) { + obj.metadata = Metadata.fromJson(__metadataObj); } - String __impactedItemJson = JsonUtil.getObject(json, "impacted_item"); - if (__impactedItemJson != null) { - obj.impactedItem = ImpactedItem.fromJson(__impactedItemJson); + JsonObject __impactedItemObj = JsonUtil.getJsonObject(jsonObj, "impacted_item"); + if (__impactedItemObj != null) { + obj.impactedItem = ImpactedItem.fromJson(__impactedItemObj); } - String __impactedSubscriptionJson = JsonUtil.getObject(json, "impacted_subscription"); - if (__impactedSubscriptionJson != null) { - obj.impactedSubscription = ImpactedSubscription.fromJson(__impactedSubscriptionJson); + JsonObject __impactedSubscriptionObj = + JsonUtil.getJsonObject(jsonObj, "impacted_subscription"); + if (__impactedSubscriptionObj != null) { + obj.impactedSubscription = ImpactedSubscription.fromJson(__impactedSubscriptionObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/FeatureReactivatedEvent.java b/src/main/java/com/chargebee/v4/models/event/FeatureReactivatedEvent.java index 843a2f90..092c1db3 100644 --- a/src/main/java/com/chargebee/v4/models/event/FeatureReactivatedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/FeatureReactivatedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.metadata.Metadata; @@ -57,25 +58,29 @@ public Content getContent() { } public static FeatureReactivatedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static FeatureReactivatedEvent fromJson(JsonObject jsonObj) { FeatureReactivatedEvent obj = new FeatureReactivatedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -140,16 +145,20 @@ public Metadata getMetadata() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __featureJson = JsonUtil.getObject(json, "feature"); - if (__featureJson != null) { - obj.feature = Feature.fromJson(__featureJson); + JsonObject __featureObj = JsonUtil.getJsonObject(jsonObj, "feature"); + if (__featureObj != null) { + obj.feature = Feature.fromJson(__featureObj); } - String __metadataJson = JsonUtil.getObject(json, "metadata"); - if (__metadataJson != null) { - obj.metadata = Metadata.fromJson(__metadataJson); + JsonObject __metadataObj = JsonUtil.getJsonObject(jsonObj, "metadata"); + if (__metadataObj != null) { + obj.metadata = Metadata.fromJson(__metadataObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/FeatureUpdatedEvent.java b/src/main/java/com/chargebee/v4/models/event/FeatureUpdatedEvent.java index cfacb08e..7e0606d6 100644 --- a/src/main/java/com/chargebee/v4/models/event/FeatureUpdatedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/FeatureUpdatedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.metadata.Metadata; @@ -57,25 +58,29 @@ public Content getContent() { } public static FeatureUpdatedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static FeatureUpdatedEvent fromJson(JsonObject jsonObj) { FeatureUpdatedEvent obj = new FeatureUpdatedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -140,16 +145,20 @@ public Metadata getMetadata() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __featureJson = JsonUtil.getObject(json, "feature"); - if (__featureJson != null) { - obj.feature = Feature.fromJson(__featureJson); + JsonObject __featureObj = JsonUtil.getJsonObject(jsonObj, "feature"); + if (__featureObj != null) { + obj.feature = Feature.fromJson(__featureObj); } - String __metadataJson = JsonUtil.getObject(json, "metadata"); - if (__metadataJson != null) { - obj.metadata = Metadata.fromJson(__metadataJson); + JsonObject __metadataObj = JsonUtil.getJsonObject(jsonObj, "metadata"); + if (__metadataObj != null) { + obj.metadata = Metadata.fromJson(__metadataObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/GiftCancelledEvent.java b/src/main/java/com/chargebee/v4/models/event/GiftCancelledEvent.java index ad025213..21e9e199 100644 --- a/src/main/java/com/chargebee/v4/models/event/GiftCancelledEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/GiftCancelledEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.gift.Gift; @@ -55,25 +56,29 @@ public Content getContent() { } public static GiftCancelledEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static GiftCancelledEvent fromJson(JsonObject jsonObj) { GiftCancelledEvent obj = new GiftCancelledEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -133,11 +138,15 @@ public Gift getGift() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __giftJson = JsonUtil.getObject(json, "gift"); - if (__giftJson != null) { - obj.gift = Gift.fromJson(__giftJson); + JsonObject __giftObj = JsonUtil.getJsonObject(jsonObj, "gift"); + if (__giftObj != null) { + obj.gift = Gift.fromJson(__giftObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/GiftClaimedEvent.java b/src/main/java/com/chargebee/v4/models/event/GiftClaimedEvent.java index 1c39313a..2e02583e 100644 --- a/src/main/java/com/chargebee/v4/models/event/GiftClaimedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/GiftClaimedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.gift.Gift; @@ -55,25 +56,29 @@ public Content getContent() { } public static GiftClaimedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static GiftClaimedEvent fromJson(JsonObject jsonObj) { GiftClaimedEvent obj = new GiftClaimedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -133,11 +138,15 @@ public Gift getGift() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __giftJson = JsonUtil.getObject(json, "gift"); - if (__giftJson != null) { - obj.gift = Gift.fromJson(__giftJson); + JsonObject __giftObj = JsonUtil.getJsonObject(jsonObj, "gift"); + if (__giftObj != null) { + obj.gift = Gift.fromJson(__giftObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/GiftExpiredEvent.java b/src/main/java/com/chargebee/v4/models/event/GiftExpiredEvent.java index eac865f6..8197cc07 100644 --- a/src/main/java/com/chargebee/v4/models/event/GiftExpiredEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/GiftExpiredEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.gift.Gift; @@ -55,25 +56,29 @@ public Content getContent() { } public static GiftExpiredEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static GiftExpiredEvent fromJson(JsonObject jsonObj) { GiftExpiredEvent obj = new GiftExpiredEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -133,11 +138,15 @@ public Gift getGift() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __giftJson = JsonUtil.getObject(json, "gift"); - if (__giftJson != null) { - obj.gift = Gift.fromJson(__giftJson); + JsonObject __giftObj = JsonUtil.getJsonObject(jsonObj, "gift"); + if (__giftObj != null) { + obj.gift = Gift.fromJson(__giftObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/GiftScheduledEvent.java b/src/main/java/com/chargebee/v4/models/event/GiftScheduledEvent.java index bf9ed5d6..23228f5c 100644 --- a/src/main/java/com/chargebee/v4/models/event/GiftScheduledEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/GiftScheduledEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.gift.Gift; @@ -55,25 +56,29 @@ public Content getContent() { } public static GiftScheduledEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static GiftScheduledEvent fromJson(JsonObject jsonObj) { GiftScheduledEvent obj = new GiftScheduledEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -133,11 +138,15 @@ public Gift getGift() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __giftJson = JsonUtil.getObject(json, "gift"); - if (__giftJson != null) { - obj.gift = Gift.fromJson(__giftJson); + JsonObject __giftObj = JsonUtil.getJsonObject(jsonObj, "gift"); + if (__giftObj != null) { + obj.gift = Gift.fromJson(__giftObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/GiftUnclaimedEvent.java b/src/main/java/com/chargebee/v4/models/event/GiftUnclaimedEvent.java index 8bbeef44..03ba5140 100644 --- a/src/main/java/com/chargebee/v4/models/event/GiftUnclaimedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/GiftUnclaimedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.gift.Gift; @@ -55,25 +56,29 @@ public Content getContent() { } public static GiftUnclaimedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static GiftUnclaimedEvent fromJson(JsonObject jsonObj) { GiftUnclaimedEvent obj = new GiftUnclaimedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -133,11 +138,15 @@ public Gift getGift() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __giftJson = JsonUtil.getObject(json, "gift"); - if (__giftJson != null) { - obj.gift = Gift.fromJson(__giftJson); + JsonObject __giftObj = JsonUtil.getJsonObject(jsonObj, "gift"); + if (__giftObj != null) { + obj.gift = Gift.fromJson(__giftObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/GiftUpdatedEvent.java b/src/main/java/com/chargebee/v4/models/event/GiftUpdatedEvent.java index 98c42092..0c4f1eff 100644 --- a/src/main/java/com/chargebee/v4/models/event/GiftUpdatedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/GiftUpdatedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.gift.Gift; @@ -55,25 +56,29 @@ public Content getContent() { } public static GiftUpdatedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static GiftUpdatedEvent fromJson(JsonObject jsonObj) { GiftUpdatedEvent obj = new GiftUpdatedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -133,11 +138,15 @@ public Gift getGift() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __giftJson = JsonUtil.getObject(json, "gift"); - if (__giftJson != null) { - obj.gift = Gift.fromJson(__giftJson); + JsonObject __giftObj = JsonUtil.getJsonObject(jsonObj, "gift"); + if (__giftObj != null) { + obj.gift = Gift.fromJson(__giftObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/HierarchyCreatedEvent.java b/src/main/java/com/chargebee/v4/models/event/HierarchyCreatedEvent.java index 3be1b05e..f677e654 100644 --- a/src/main/java/com/chargebee/v4/models/event/HierarchyCreatedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/HierarchyCreatedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.customer.Customer; @@ -55,25 +56,29 @@ public Content getContent() { } public static HierarchyCreatedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static HierarchyCreatedEvent fromJson(JsonObject jsonObj) { HierarchyCreatedEvent obj = new HierarchyCreatedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -133,11 +138,15 @@ public Customer getCustomer() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - obj.customer = Customer.fromJson(__customerJson); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + obj.customer = Customer.fromJson(__customerObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/HierarchyDeletedEvent.java b/src/main/java/com/chargebee/v4/models/event/HierarchyDeletedEvent.java index 75e9147a..456ee4a3 100644 --- a/src/main/java/com/chargebee/v4/models/event/HierarchyDeletedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/HierarchyDeletedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.customer.Customer; @@ -55,25 +56,29 @@ public Content getContent() { } public static HierarchyDeletedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static HierarchyDeletedEvent fromJson(JsonObject jsonObj) { HierarchyDeletedEvent obj = new HierarchyDeletedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -133,11 +138,15 @@ public Customer getCustomer() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - obj.customer = Customer.fromJson(__customerJson); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + obj.customer = Customer.fromJson(__customerObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/InvoiceDeletedEvent.java b/src/main/java/com/chargebee/v4/models/event/InvoiceDeletedEvent.java index 4e99e7ee..b6bdf220 100644 --- a/src/main/java/com/chargebee/v4/models/event/InvoiceDeletedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/InvoiceDeletedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.invoice.Invoice; @@ -55,25 +56,29 @@ public Content getContent() { } public static InvoiceDeletedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static InvoiceDeletedEvent fromJson(JsonObject jsonObj) { InvoiceDeletedEvent obj = new InvoiceDeletedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -133,11 +138,15 @@ public Invoice getInvoice() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __invoiceJson = JsonUtil.getObject(json, "invoice"); - if (__invoiceJson != null) { - obj.invoice = Invoice.fromJson(__invoiceJson); + JsonObject __invoiceObj = JsonUtil.getJsonObject(jsonObj, "invoice"); + if (__invoiceObj != null) { + obj.invoice = Invoice.fromJson(__invoiceObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/InvoiceGeneratedEvent.java b/src/main/java/com/chargebee/v4/models/event/InvoiceGeneratedEvent.java index a2708e94..b4c4d8c3 100644 --- a/src/main/java/com/chargebee/v4/models/event/InvoiceGeneratedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/InvoiceGeneratedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.invoice.Invoice; @@ -55,25 +56,29 @@ public Content getContent() { } public static InvoiceGeneratedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static InvoiceGeneratedEvent fromJson(JsonObject jsonObj) { InvoiceGeneratedEvent obj = new InvoiceGeneratedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -133,11 +138,15 @@ public Invoice getInvoice() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __invoiceJson = JsonUtil.getObject(json, "invoice"); - if (__invoiceJson != null) { - obj.invoice = Invoice.fromJson(__invoiceJson); + JsonObject __invoiceObj = JsonUtil.getJsonObject(jsonObj, "invoice"); + if (__invoiceObj != null) { + obj.invoice = Invoice.fromJson(__invoiceObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/InvoiceGeneratedWithBackdatingEvent.java b/src/main/java/com/chargebee/v4/models/event/InvoiceGeneratedWithBackdatingEvent.java index c918222a..536d9ea0 100644 --- a/src/main/java/com/chargebee/v4/models/event/InvoiceGeneratedWithBackdatingEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/InvoiceGeneratedWithBackdatingEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.invoice.Invoice; @@ -55,25 +56,29 @@ public Content getContent() { } public static InvoiceGeneratedWithBackdatingEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static InvoiceGeneratedWithBackdatingEvent fromJson(JsonObject jsonObj) { InvoiceGeneratedWithBackdatingEvent obj = new InvoiceGeneratedWithBackdatingEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -133,11 +138,15 @@ public Invoice getInvoice() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __invoiceJson = JsonUtil.getObject(json, "invoice"); - if (__invoiceJson != null) { - obj.invoice = Invoice.fromJson(__invoiceJson); + JsonObject __invoiceObj = JsonUtil.getJsonObject(jsonObj, "invoice"); + if (__invoiceObj != null) { + obj.invoice = Invoice.fromJson(__invoiceObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/InvoiceUpdatedEvent.java b/src/main/java/com/chargebee/v4/models/event/InvoiceUpdatedEvent.java index 23779bbe..72959487 100644 --- a/src/main/java/com/chargebee/v4/models/event/InvoiceUpdatedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/InvoiceUpdatedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.invoice.Invoice; @@ -55,25 +56,29 @@ public Content getContent() { } public static InvoiceUpdatedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static InvoiceUpdatedEvent fromJson(JsonObject jsonObj) { InvoiceUpdatedEvent obj = new InvoiceUpdatedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -133,11 +138,15 @@ public Invoice getInvoice() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __invoiceJson = JsonUtil.getObject(json, "invoice"); - if (__invoiceJson != null) { - obj.invoice = Invoice.fromJson(__invoiceJson); + JsonObject __invoiceObj = JsonUtil.getJsonObject(jsonObj, "invoice"); + if (__invoiceObj != null) { + obj.invoice = Invoice.fromJson(__invoiceObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/ItemCreatedEvent.java b/src/main/java/com/chargebee/v4/models/event/ItemCreatedEvent.java index f58e9ccd..7abd61d2 100644 --- a/src/main/java/com/chargebee/v4/models/event/ItemCreatedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/ItemCreatedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.item.Item; @@ -55,25 +56,29 @@ public Content getContent() { } public static ItemCreatedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static ItemCreatedEvent fromJson(JsonObject jsonObj) { ItemCreatedEvent obj = new ItemCreatedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -133,11 +138,15 @@ public Item getItem() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __itemJson = JsonUtil.getObject(json, "item"); - if (__itemJson != null) { - obj.item = Item.fromJson(__itemJson); + JsonObject __itemObj = JsonUtil.getJsonObject(jsonObj, "item"); + if (__itemObj != null) { + obj.item = Item.fromJson(__itemObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/ItemDeletedEvent.java b/src/main/java/com/chargebee/v4/models/event/ItemDeletedEvent.java index d587af3a..b2c8297e 100644 --- a/src/main/java/com/chargebee/v4/models/event/ItemDeletedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/ItemDeletedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.item.Item; @@ -55,25 +56,29 @@ public Content getContent() { } public static ItemDeletedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static ItemDeletedEvent fromJson(JsonObject jsonObj) { ItemDeletedEvent obj = new ItemDeletedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -133,11 +138,15 @@ public Item getItem() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __itemJson = JsonUtil.getObject(json, "item"); - if (__itemJson != null) { - obj.item = Item.fromJson(__itemJson); + JsonObject __itemObj = JsonUtil.getJsonObject(jsonObj, "item"); + if (__itemObj != null) { + obj.item = Item.fromJson(__itemObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/ItemEntitlementsRemovedEvent.java b/src/main/java/com/chargebee/v4/models/event/ItemEntitlementsRemovedEvent.java index 6d2e6481..8cc7013d 100644 --- a/src/main/java/com/chargebee/v4/models/event/ItemEntitlementsRemovedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/ItemEntitlementsRemovedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.impactedItem.ImpactedItem; @@ -61,25 +62,29 @@ public Content getContent() { } public static ItemEntitlementsRemovedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static ItemEntitlementsRemovedEvent fromJson(JsonObject jsonObj) { ItemEntitlementsRemovedEvent obj = new ItemEntitlementsRemovedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -154,26 +159,31 @@ public ImpactedSubscription getImpactedSubscription() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __featureJson = JsonUtil.getObject(json, "feature"); - if (__featureJson != null) { - obj.feature = Feature.fromJson(__featureJson); + JsonObject __featureObj = JsonUtil.getJsonObject(jsonObj, "feature"); + if (__featureObj != null) { + obj.feature = Feature.fromJson(__featureObj); } - String __metadataJson = JsonUtil.getObject(json, "metadata"); - if (__metadataJson != null) { - obj.metadata = Metadata.fromJson(__metadataJson); + JsonObject __metadataObj = JsonUtil.getJsonObject(jsonObj, "metadata"); + if (__metadataObj != null) { + obj.metadata = Metadata.fromJson(__metadataObj); } - String __impactedItemJson = JsonUtil.getObject(json, "impacted_item"); - if (__impactedItemJson != null) { - obj.impactedItem = ImpactedItem.fromJson(__impactedItemJson); + JsonObject __impactedItemObj = JsonUtil.getJsonObject(jsonObj, "impacted_item"); + if (__impactedItemObj != null) { + obj.impactedItem = ImpactedItem.fromJson(__impactedItemObj); } - String __impactedSubscriptionJson = JsonUtil.getObject(json, "impacted_subscription"); - if (__impactedSubscriptionJson != null) { - obj.impactedSubscription = ImpactedSubscription.fromJson(__impactedSubscriptionJson); + JsonObject __impactedSubscriptionObj = + JsonUtil.getJsonObject(jsonObj, "impacted_subscription"); + if (__impactedSubscriptionObj != null) { + obj.impactedSubscription = ImpactedSubscription.fromJson(__impactedSubscriptionObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/ItemEntitlementsUpdatedEvent.java b/src/main/java/com/chargebee/v4/models/event/ItemEntitlementsUpdatedEvent.java index e0c9563d..cf35e76b 100644 --- a/src/main/java/com/chargebee/v4/models/event/ItemEntitlementsUpdatedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/ItemEntitlementsUpdatedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.impactedItem.ImpactedItem; @@ -61,25 +62,29 @@ public Content getContent() { } public static ItemEntitlementsUpdatedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static ItemEntitlementsUpdatedEvent fromJson(JsonObject jsonObj) { ItemEntitlementsUpdatedEvent obj = new ItemEntitlementsUpdatedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -154,26 +159,31 @@ public ImpactedSubscription getImpactedSubscription() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __featureJson = JsonUtil.getObject(json, "feature"); - if (__featureJson != null) { - obj.feature = Feature.fromJson(__featureJson); + JsonObject __featureObj = JsonUtil.getJsonObject(jsonObj, "feature"); + if (__featureObj != null) { + obj.feature = Feature.fromJson(__featureObj); } - String __metadataJson = JsonUtil.getObject(json, "metadata"); - if (__metadataJson != null) { - obj.metadata = Metadata.fromJson(__metadataJson); + JsonObject __metadataObj = JsonUtil.getJsonObject(jsonObj, "metadata"); + if (__metadataObj != null) { + obj.metadata = Metadata.fromJson(__metadataObj); } - String __impactedItemJson = JsonUtil.getObject(json, "impacted_item"); - if (__impactedItemJson != null) { - obj.impactedItem = ImpactedItem.fromJson(__impactedItemJson); + JsonObject __impactedItemObj = JsonUtil.getJsonObject(jsonObj, "impacted_item"); + if (__impactedItemObj != null) { + obj.impactedItem = ImpactedItem.fromJson(__impactedItemObj); } - String __impactedSubscriptionJson = JsonUtil.getObject(json, "impacted_subscription"); - if (__impactedSubscriptionJson != null) { - obj.impactedSubscription = ImpactedSubscription.fromJson(__impactedSubscriptionJson); + JsonObject __impactedSubscriptionObj = + JsonUtil.getJsonObject(jsonObj, "impacted_subscription"); + if (__impactedSubscriptionObj != null) { + obj.impactedSubscription = ImpactedSubscription.fromJson(__impactedSubscriptionObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/ItemFamilyCreatedEvent.java b/src/main/java/com/chargebee/v4/models/event/ItemFamilyCreatedEvent.java index 89f43cbe..eb38b336 100644 --- a/src/main/java/com/chargebee/v4/models/event/ItemFamilyCreatedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/ItemFamilyCreatedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.itemFamily.ItemFamily; @@ -55,25 +56,29 @@ public Content getContent() { } public static ItemFamilyCreatedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static ItemFamilyCreatedEvent fromJson(JsonObject jsonObj) { ItemFamilyCreatedEvent obj = new ItemFamilyCreatedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -133,11 +138,15 @@ public ItemFamily getItemFamily() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __itemFamilyJson = JsonUtil.getObject(json, "item_family"); - if (__itemFamilyJson != null) { - obj.itemFamily = ItemFamily.fromJson(__itemFamilyJson); + JsonObject __itemFamilyObj = JsonUtil.getJsonObject(jsonObj, "item_family"); + if (__itemFamilyObj != null) { + obj.itemFamily = ItemFamily.fromJson(__itemFamilyObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/ItemFamilyDeletedEvent.java b/src/main/java/com/chargebee/v4/models/event/ItemFamilyDeletedEvent.java index f8f4a2e7..a17300c0 100644 --- a/src/main/java/com/chargebee/v4/models/event/ItemFamilyDeletedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/ItemFamilyDeletedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.itemFamily.ItemFamily; @@ -55,25 +56,29 @@ public Content getContent() { } public static ItemFamilyDeletedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static ItemFamilyDeletedEvent fromJson(JsonObject jsonObj) { ItemFamilyDeletedEvent obj = new ItemFamilyDeletedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -133,11 +138,15 @@ public ItemFamily getItemFamily() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __itemFamilyJson = JsonUtil.getObject(json, "item_family"); - if (__itemFamilyJson != null) { - obj.itemFamily = ItemFamily.fromJson(__itemFamilyJson); + JsonObject __itemFamilyObj = JsonUtil.getJsonObject(jsonObj, "item_family"); + if (__itemFamilyObj != null) { + obj.itemFamily = ItemFamily.fromJson(__itemFamilyObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/ItemFamilyUpdatedEvent.java b/src/main/java/com/chargebee/v4/models/event/ItemFamilyUpdatedEvent.java index 0c70dde0..7f6acda1 100644 --- a/src/main/java/com/chargebee/v4/models/event/ItemFamilyUpdatedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/ItemFamilyUpdatedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.itemFamily.ItemFamily; @@ -55,25 +56,29 @@ public Content getContent() { } public static ItemFamilyUpdatedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static ItemFamilyUpdatedEvent fromJson(JsonObject jsonObj) { ItemFamilyUpdatedEvent obj = new ItemFamilyUpdatedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -133,11 +138,15 @@ public ItemFamily getItemFamily() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __itemFamilyJson = JsonUtil.getObject(json, "item_family"); - if (__itemFamilyJson != null) { - obj.itemFamily = ItemFamily.fromJson(__itemFamilyJson); + JsonObject __itemFamilyObj = JsonUtil.getJsonObject(jsonObj, "item_family"); + if (__itemFamilyObj != null) { + obj.itemFamily = ItemFamily.fromJson(__itemFamilyObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/ItemPriceCreatedEvent.java b/src/main/java/com/chargebee/v4/models/event/ItemPriceCreatedEvent.java index 575b468a..dcfa7a92 100644 --- a/src/main/java/com/chargebee/v4/models/event/ItemPriceCreatedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/ItemPriceCreatedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.itemPrice.ItemPrice; @@ -55,25 +56,29 @@ public Content getContent() { } public static ItemPriceCreatedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static ItemPriceCreatedEvent fromJson(JsonObject jsonObj) { ItemPriceCreatedEvent obj = new ItemPriceCreatedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -133,11 +138,15 @@ public ItemPrice getItemPrice() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __itemPriceJson = JsonUtil.getObject(json, "item_price"); - if (__itemPriceJson != null) { - obj.itemPrice = ItemPrice.fromJson(__itemPriceJson); + JsonObject __itemPriceObj = JsonUtil.getJsonObject(jsonObj, "item_price"); + if (__itemPriceObj != null) { + obj.itemPrice = ItemPrice.fromJson(__itemPriceObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/ItemPriceDeletedEvent.java b/src/main/java/com/chargebee/v4/models/event/ItemPriceDeletedEvent.java index c794a36f..f60443a0 100644 --- a/src/main/java/com/chargebee/v4/models/event/ItemPriceDeletedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/ItemPriceDeletedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.itemPrice.ItemPrice; @@ -55,25 +56,29 @@ public Content getContent() { } public static ItemPriceDeletedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static ItemPriceDeletedEvent fromJson(JsonObject jsonObj) { ItemPriceDeletedEvent obj = new ItemPriceDeletedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -133,11 +138,15 @@ public ItemPrice getItemPrice() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __itemPriceJson = JsonUtil.getObject(json, "item_price"); - if (__itemPriceJson != null) { - obj.itemPrice = ItemPrice.fromJson(__itemPriceJson); + JsonObject __itemPriceObj = JsonUtil.getJsonObject(jsonObj, "item_price"); + if (__itemPriceObj != null) { + obj.itemPrice = ItemPrice.fromJson(__itemPriceObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/ItemPriceEntitlementsRemovedEvent.java b/src/main/java/com/chargebee/v4/models/event/ItemPriceEntitlementsRemovedEvent.java index 91e8319a..98f6a3ae 100644 --- a/src/main/java/com/chargebee/v4/models/event/ItemPriceEntitlementsRemovedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/ItemPriceEntitlementsRemovedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.metadata.Metadata; @@ -61,25 +62,29 @@ public Content getContent() { } public static ItemPriceEntitlementsRemovedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static ItemPriceEntitlementsRemovedEvent fromJson(JsonObject jsonObj) { ItemPriceEntitlementsRemovedEvent obj = new ItemPriceEntitlementsRemovedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -154,26 +159,31 @@ public ImpactedSubscription getImpactedSubscription() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __featureJson = JsonUtil.getObject(json, "feature"); - if (__featureJson != null) { - obj.feature = Feature.fromJson(__featureJson); + JsonObject __featureObj = JsonUtil.getJsonObject(jsonObj, "feature"); + if (__featureObj != null) { + obj.feature = Feature.fromJson(__featureObj); } - String __metadataJson = JsonUtil.getObject(json, "metadata"); - if (__metadataJson != null) { - obj.metadata = Metadata.fromJson(__metadataJson); + JsonObject __metadataObj = JsonUtil.getJsonObject(jsonObj, "metadata"); + if (__metadataObj != null) { + obj.metadata = Metadata.fromJson(__metadataObj); } - String __impactedItemPriceJson = JsonUtil.getObject(json, "impacted_item_price"); - if (__impactedItemPriceJson != null) { - obj.impactedItemPrice = ImpactedItemPrice.fromJson(__impactedItemPriceJson); + JsonObject __impactedItemPriceObj = JsonUtil.getJsonObject(jsonObj, "impacted_item_price"); + if (__impactedItemPriceObj != null) { + obj.impactedItemPrice = ImpactedItemPrice.fromJson(__impactedItemPriceObj); } - String __impactedSubscriptionJson = JsonUtil.getObject(json, "impacted_subscription"); - if (__impactedSubscriptionJson != null) { - obj.impactedSubscription = ImpactedSubscription.fromJson(__impactedSubscriptionJson); + JsonObject __impactedSubscriptionObj = + JsonUtil.getJsonObject(jsonObj, "impacted_subscription"); + if (__impactedSubscriptionObj != null) { + obj.impactedSubscription = ImpactedSubscription.fromJson(__impactedSubscriptionObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/ItemPriceEntitlementsUpdatedEvent.java b/src/main/java/com/chargebee/v4/models/event/ItemPriceEntitlementsUpdatedEvent.java index 2d7ca53f..cbdee157 100644 --- a/src/main/java/com/chargebee/v4/models/event/ItemPriceEntitlementsUpdatedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/ItemPriceEntitlementsUpdatedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.metadata.Metadata; @@ -61,25 +62,29 @@ public Content getContent() { } public static ItemPriceEntitlementsUpdatedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static ItemPriceEntitlementsUpdatedEvent fromJson(JsonObject jsonObj) { ItemPriceEntitlementsUpdatedEvent obj = new ItemPriceEntitlementsUpdatedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -154,26 +159,31 @@ public ImpactedSubscription getImpactedSubscription() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __featureJson = JsonUtil.getObject(json, "feature"); - if (__featureJson != null) { - obj.feature = Feature.fromJson(__featureJson); + JsonObject __featureObj = JsonUtil.getJsonObject(jsonObj, "feature"); + if (__featureObj != null) { + obj.feature = Feature.fromJson(__featureObj); } - String __metadataJson = JsonUtil.getObject(json, "metadata"); - if (__metadataJson != null) { - obj.metadata = Metadata.fromJson(__metadataJson); + JsonObject __metadataObj = JsonUtil.getJsonObject(jsonObj, "metadata"); + if (__metadataObj != null) { + obj.metadata = Metadata.fromJson(__metadataObj); } - String __impactedItemPriceJson = JsonUtil.getObject(json, "impacted_item_price"); - if (__impactedItemPriceJson != null) { - obj.impactedItemPrice = ImpactedItemPrice.fromJson(__impactedItemPriceJson); + JsonObject __impactedItemPriceObj = JsonUtil.getJsonObject(jsonObj, "impacted_item_price"); + if (__impactedItemPriceObj != null) { + obj.impactedItemPrice = ImpactedItemPrice.fromJson(__impactedItemPriceObj); } - String __impactedSubscriptionJson = JsonUtil.getObject(json, "impacted_subscription"); - if (__impactedSubscriptionJson != null) { - obj.impactedSubscription = ImpactedSubscription.fromJson(__impactedSubscriptionJson); + JsonObject __impactedSubscriptionObj = + JsonUtil.getJsonObject(jsonObj, "impacted_subscription"); + if (__impactedSubscriptionObj != null) { + obj.impactedSubscription = ImpactedSubscription.fromJson(__impactedSubscriptionObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/ItemPriceUpdatedEvent.java b/src/main/java/com/chargebee/v4/models/event/ItemPriceUpdatedEvent.java index 942fd185..52a769d7 100644 --- a/src/main/java/com/chargebee/v4/models/event/ItemPriceUpdatedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/ItemPriceUpdatedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.itemPrice.ItemPrice; @@ -55,25 +56,29 @@ public Content getContent() { } public static ItemPriceUpdatedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static ItemPriceUpdatedEvent fromJson(JsonObject jsonObj) { ItemPriceUpdatedEvent obj = new ItemPriceUpdatedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -133,11 +138,15 @@ public ItemPrice getItemPrice() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __itemPriceJson = JsonUtil.getObject(json, "item_price"); - if (__itemPriceJson != null) { - obj.itemPrice = ItemPrice.fromJson(__itemPriceJson); + JsonObject __itemPriceObj = JsonUtil.getJsonObject(jsonObj, "item_price"); + if (__itemPriceObj != null) { + obj.itemPrice = ItemPrice.fromJson(__itemPriceObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/ItemUpdatedEvent.java b/src/main/java/com/chargebee/v4/models/event/ItemUpdatedEvent.java index 1958978d..0a813d1c 100644 --- a/src/main/java/com/chargebee/v4/models/event/ItemUpdatedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/ItemUpdatedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.item.Item; @@ -55,25 +56,29 @@ public Content getContent() { } public static ItemUpdatedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static ItemUpdatedEvent fromJson(JsonObject jsonObj) { ItemUpdatedEvent obj = new ItemUpdatedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -133,11 +138,15 @@ public Item getItem() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __itemJson = JsonUtil.getObject(json, "item"); - if (__itemJson != null) { - obj.item = Item.fromJson(__itemJson); + JsonObject __itemObj = JsonUtil.getJsonObject(jsonObj, "item"); + if (__itemObj != null) { + obj.item = Item.fromJson(__itemObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/MrrUpdatedEvent.java b/src/main/java/com/chargebee/v4/models/event/MrrUpdatedEvent.java index 8c7c1075..08567595 100644 --- a/src/main/java/com/chargebee/v4/models/event/MrrUpdatedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/MrrUpdatedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.subscription.Subscription; @@ -55,25 +56,29 @@ public Content getContent() { } public static MrrUpdatedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static MrrUpdatedEvent fromJson(JsonObject jsonObj) { MrrUpdatedEvent obj = new MrrUpdatedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -133,11 +138,15 @@ public Subscription getSubscription() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __subscriptionJson = JsonUtil.getObject(json, "subscription"); - if (__subscriptionJson != null) { - obj.subscription = Subscription.fromJson(__subscriptionJson); + JsonObject __subscriptionObj = JsonUtil.getJsonObject(jsonObj, "subscription"); + if (__subscriptionObj != null) { + obj.subscription = Subscription.fromJson(__subscriptionObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/NetdPaymentDueReminderEvent.java b/src/main/java/com/chargebee/v4/models/event/NetdPaymentDueReminderEvent.java index 1a7b1657..fb269b34 100644 --- a/src/main/java/com/chargebee/v4/models/event/NetdPaymentDueReminderEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/NetdPaymentDueReminderEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.invoice.Invoice; @@ -55,25 +56,29 @@ public Content getContent() { } public static NetdPaymentDueReminderEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static NetdPaymentDueReminderEvent fromJson(JsonObject jsonObj) { NetdPaymentDueReminderEvent obj = new NetdPaymentDueReminderEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -133,11 +138,15 @@ public Invoice getInvoice() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __invoiceJson = JsonUtil.getObject(json, "invoice"); - if (__invoiceJson != null) { - obj.invoice = Invoice.fromJson(__invoiceJson); + JsonObject __invoiceObj = JsonUtil.getJsonObject(jsonObj, "invoice"); + if (__invoiceObj != null) { + obj.invoice = Invoice.fromJson(__invoiceObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/OmnichannelOneTimeOrderCreatedEvent.java b/src/main/java/com/chargebee/v4/models/event/OmnichannelOneTimeOrderCreatedEvent.java index 103aeef0..9c965690 100644 --- a/src/main/java/com/chargebee/v4/models/event/OmnichannelOneTimeOrderCreatedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/OmnichannelOneTimeOrderCreatedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.customer.Customer; @@ -61,25 +62,29 @@ public Content getContent() { } public static OmnichannelOneTimeOrderCreatedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static OmnichannelOneTimeOrderCreatedEvent fromJson(JsonObject jsonObj) { OmnichannelOneTimeOrderCreatedEvent obj = new OmnichannelOneTimeOrderCreatedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -154,29 +159,35 @@ public Customer getCustomer() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __omnichannelOneTimeOrderJson = JsonUtil.getObject(json, "omnichannel_one_time_order"); - if (__omnichannelOneTimeOrderJson != null) { + JsonObject __omnichannelOneTimeOrderObj = + JsonUtil.getJsonObject(jsonObj, "omnichannel_one_time_order"); + if (__omnichannelOneTimeOrderObj != null) { obj.omnichannelOneTimeOrder = - OmnichannelOneTimeOrder.fromJson(__omnichannelOneTimeOrderJson); + OmnichannelOneTimeOrder.fromJson(__omnichannelOneTimeOrderObj); } - String __omnichannelOneTimeOrderItemJson = - JsonUtil.getObject(json, "omnichannel_one_time_order_item"); - if (__omnichannelOneTimeOrderItemJson != null) { + JsonObject __omnichannelOneTimeOrderItemObj = + JsonUtil.getJsonObject(jsonObj, "omnichannel_one_time_order_item"); + if (__omnichannelOneTimeOrderItemObj != null) { obj.omnichannelOneTimeOrderItem = - OmnichannelOneTimeOrderItem.fromJson(__omnichannelOneTimeOrderItemJson); + OmnichannelOneTimeOrderItem.fromJson(__omnichannelOneTimeOrderItemObj); } - String __omnichannelTransactionJson = JsonUtil.getObject(json, "omnichannel_transaction"); - if (__omnichannelTransactionJson != null) { - obj.omnichannelTransaction = OmnichannelTransaction.fromJson(__omnichannelTransactionJson); + JsonObject __omnichannelTransactionObj = + JsonUtil.getJsonObject(jsonObj, "omnichannel_transaction"); + if (__omnichannelTransactionObj != null) { + obj.omnichannelTransaction = OmnichannelTransaction.fromJson(__omnichannelTransactionObj); } - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - obj.customer = Customer.fromJson(__customerJson); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + obj.customer = Customer.fromJson(__customerObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/OmnichannelOneTimeOrderItemCancelledEvent.java b/src/main/java/com/chargebee/v4/models/event/OmnichannelOneTimeOrderItemCancelledEvent.java index 8e40024b..4b1cd0b1 100644 --- a/src/main/java/com/chargebee/v4/models/event/OmnichannelOneTimeOrderItemCancelledEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/OmnichannelOneTimeOrderItemCancelledEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.customer.Customer; @@ -61,25 +62,29 @@ public Content getContent() { } public static OmnichannelOneTimeOrderItemCancelledEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static OmnichannelOneTimeOrderItemCancelledEvent fromJson(JsonObject jsonObj) { OmnichannelOneTimeOrderItemCancelledEvent obj = new OmnichannelOneTimeOrderItemCancelledEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -154,29 +159,35 @@ public Customer getCustomer() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __omnichannelOneTimeOrderJson = JsonUtil.getObject(json, "omnichannel_one_time_order"); - if (__omnichannelOneTimeOrderJson != null) { + JsonObject __omnichannelOneTimeOrderObj = + JsonUtil.getJsonObject(jsonObj, "omnichannel_one_time_order"); + if (__omnichannelOneTimeOrderObj != null) { obj.omnichannelOneTimeOrder = - OmnichannelOneTimeOrder.fromJson(__omnichannelOneTimeOrderJson); + OmnichannelOneTimeOrder.fromJson(__omnichannelOneTimeOrderObj); } - String __omnichannelOneTimeOrderItemJson = - JsonUtil.getObject(json, "omnichannel_one_time_order_item"); - if (__omnichannelOneTimeOrderItemJson != null) { + JsonObject __omnichannelOneTimeOrderItemObj = + JsonUtil.getJsonObject(jsonObj, "omnichannel_one_time_order_item"); + if (__omnichannelOneTimeOrderItemObj != null) { obj.omnichannelOneTimeOrderItem = - OmnichannelOneTimeOrderItem.fromJson(__omnichannelOneTimeOrderItemJson); + OmnichannelOneTimeOrderItem.fromJson(__omnichannelOneTimeOrderItemObj); } - String __omnichannelTransactionJson = JsonUtil.getObject(json, "omnichannel_transaction"); - if (__omnichannelTransactionJson != null) { - obj.omnichannelTransaction = OmnichannelTransaction.fromJson(__omnichannelTransactionJson); + JsonObject __omnichannelTransactionObj = + JsonUtil.getJsonObject(jsonObj, "omnichannel_transaction"); + if (__omnichannelTransactionObj != null) { + obj.omnichannelTransaction = OmnichannelTransaction.fromJson(__omnichannelTransactionObj); } - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - obj.customer = Customer.fromJson(__customerJson); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + obj.customer = Customer.fromJson(__customerObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/OmnichannelSubscriptionCreatedEvent.java b/src/main/java/com/chargebee/v4/models/event/OmnichannelSubscriptionCreatedEvent.java index 7d3bdf9f..8f9c0368 100644 --- a/src/main/java/com/chargebee/v4/models/event/OmnichannelSubscriptionCreatedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/OmnichannelSubscriptionCreatedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.customer.Customer; @@ -63,25 +64,29 @@ public Content getContent() { } public static OmnichannelSubscriptionCreatedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static OmnichannelSubscriptionCreatedEvent fromJson(JsonObject jsonObj) { OmnichannelSubscriptionCreatedEvent obj = new OmnichannelSubscriptionCreatedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -162,37 +167,43 @@ public Customer getCustomer() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __omnichannelSubscriptionItemJson = - JsonUtil.getObject(json, "omnichannel_subscription_item"); - if (__omnichannelSubscriptionItemJson != null) { + JsonObject __omnichannelSubscriptionItemObj = + JsonUtil.getJsonObject(jsonObj, "omnichannel_subscription_item"); + if (__omnichannelSubscriptionItemObj != null) { obj.omnichannelSubscriptionItem = - OmnichannelSubscriptionItem.fromJson(__omnichannelSubscriptionItemJson); + OmnichannelSubscriptionItem.fromJson(__omnichannelSubscriptionItemObj); } - String __omnichannelSubscriptionJson = JsonUtil.getObject(json, "omnichannel_subscription"); - if (__omnichannelSubscriptionJson != null) { + JsonObject __omnichannelSubscriptionObj = + JsonUtil.getJsonObject(jsonObj, "omnichannel_subscription"); + if (__omnichannelSubscriptionObj != null) { obj.omnichannelSubscription = - OmnichannelSubscription.fromJson(__omnichannelSubscriptionJson); + OmnichannelSubscription.fromJson(__omnichannelSubscriptionObj); } - String __omnichannelTransactionJson = JsonUtil.getObject(json, "omnichannel_transaction"); - if (__omnichannelTransactionJson != null) { - obj.omnichannelTransaction = OmnichannelTransaction.fromJson(__omnichannelTransactionJson); + JsonObject __omnichannelTransactionObj = + JsonUtil.getJsonObject(jsonObj, "omnichannel_transaction"); + if (__omnichannelTransactionObj != null) { + obj.omnichannelTransaction = OmnichannelTransaction.fromJson(__omnichannelTransactionObj); } - String __omnichannelSubscriptionItemScheduledChangeJson = - JsonUtil.getObject(json, "omnichannel_subscription_item_scheduled_change"); - if (__omnichannelSubscriptionItemScheduledChangeJson != null) { + JsonObject __omnichannelSubscriptionItemScheduledChangeObj = + JsonUtil.getJsonObject(jsonObj, "omnichannel_subscription_item_scheduled_change"); + if (__omnichannelSubscriptionItemScheduledChangeObj != null) { obj.omnichannelSubscriptionItemScheduledChange = OmnichannelSubscriptionItemScheduledChange.fromJson( - __omnichannelSubscriptionItemScheduledChangeJson); + __omnichannelSubscriptionItemScheduledChangeObj); } - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - obj.customer = Customer.fromJson(__customerJson); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + obj.customer = Customer.fromJson(__customerObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/OmnichannelSubscriptionImportedEvent.java b/src/main/java/com/chargebee/v4/models/event/OmnichannelSubscriptionImportedEvent.java index 1dbde94e..b332e376 100644 --- a/src/main/java/com/chargebee/v4/models/event/OmnichannelSubscriptionImportedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/OmnichannelSubscriptionImportedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.customer.Customer; @@ -63,25 +64,29 @@ public Content getContent() { } public static OmnichannelSubscriptionImportedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static OmnichannelSubscriptionImportedEvent fromJson(JsonObject jsonObj) { OmnichannelSubscriptionImportedEvent obj = new OmnichannelSubscriptionImportedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -162,37 +167,43 @@ public Customer getCustomer() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __omnichannelSubscriptionItemJson = - JsonUtil.getObject(json, "omnichannel_subscription_item"); - if (__omnichannelSubscriptionItemJson != null) { + JsonObject __omnichannelSubscriptionItemObj = + JsonUtil.getJsonObject(jsonObj, "omnichannel_subscription_item"); + if (__omnichannelSubscriptionItemObj != null) { obj.omnichannelSubscriptionItem = - OmnichannelSubscriptionItem.fromJson(__omnichannelSubscriptionItemJson); + OmnichannelSubscriptionItem.fromJson(__omnichannelSubscriptionItemObj); } - String __omnichannelSubscriptionJson = JsonUtil.getObject(json, "omnichannel_subscription"); - if (__omnichannelSubscriptionJson != null) { + JsonObject __omnichannelSubscriptionObj = + JsonUtil.getJsonObject(jsonObj, "omnichannel_subscription"); + if (__omnichannelSubscriptionObj != null) { obj.omnichannelSubscription = - OmnichannelSubscription.fromJson(__omnichannelSubscriptionJson); + OmnichannelSubscription.fromJson(__omnichannelSubscriptionObj); } - String __omnichannelTransactionJson = JsonUtil.getObject(json, "omnichannel_transaction"); - if (__omnichannelTransactionJson != null) { - obj.omnichannelTransaction = OmnichannelTransaction.fromJson(__omnichannelTransactionJson); + JsonObject __omnichannelTransactionObj = + JsonUtil.getJsonObject(jsonObj, "omnichannel_transaction"); + if (__omnichannelTransactionObj != null) { + obj.omnichannelTransaction = OmnichannelTransaction.fromJson(__omnichannelTransactionObj); } - String __omnichannelSubscriptionItemScheduledChangeJson = - JsonUtil.getObject(json, "omnichannel_subscription_item_scheduled_change"); - if (__omnichannelSubscriptionItemScheduledChangeJson != null) { + JsonObject __omnichannelSubscriptionItemScheduledChangeObj = + JsonUtil.getJsonObject(jsonObj, "omnichannel_subscription_item_scheduled_change"); + if (__omnichannelSubscriptionItemScheduledChangeObj != null) { obj.omnichannelSubscriptionItemScheduledChange = OmnichannelSubscriptionItemScheduledChange.fromJson( - __omnichannelSubscriptionItemScheduledChangeJson); + __omnichannelSubscriptionItemScheduledChangeObj); } - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - obj.customer = Customer.fromJson(__customerJson); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + obj.customer = Customer.fromJson(__customerObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/OmnichannelSubscriptionItemCancellationScheduledEvent.java b/src/main/java/com/chargebee/v4/models/event/OmnichannelSubscriptionItemCancellationScheduledEvent.java index e716ba2f..34867ac5 100644 --- a/src/main/java/com/chargebee/v4/models/event/OmnichannelSubscriptionItemCancellationScheduledEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/OmnichannelSubscriptionItemCancellationScheduledEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.customer.Customer; @@ -59,26 +60,30 @@ public Content getContent() { } public static OmnichannelSubscriptionItemCancellationScheduledEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static OmnichannelSubscriptionItemCancellationScheduledEvent fromJson(JsonObject jsonObj) { OmnichannelSubscriptionItemCancellationScheduledEvent obj = new OmnichannelSubscriptionItemCancellationScheduledEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -149,24 +154,29 @@ public Customer getCustomer() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __omnichannelSubscriptionJson = JsonUtil.getObject(json, "omnichannel_subscription"); - if (__omnichannelSubscriptionJson != null) { + JsonObject __omnichannelSubscriptionObj = + JsonUtil.getJsonObject(jsonObj, "omnichannel_subscription"); + if (__omnichannelSubscriptionObj != null) { obj.omnichannelSubscription = - OmnichannelSubscription.fromJson(__omnichannelSubscriptionJson); + OmnichannelSubscription.fromJson(__omnichannelSubscriptionObj); } - String __omnichannelSubscriptionItemJson = - JsonUtil.getObject(json, "omnichannel_subscription_item"); - if (__omnichannelSubscriptionItemJson != null) { + JsonObject __omnichannelSubscriptionItemObj = + JsonUtil.getJsonObject(jsonObj, "omnichannel_subscription_item"); + if (__omnichannelSubscriptionItemObj != null) { obj.omnichannelSubscriptionItem = - OmnichannelSubscriptionItem.fromJson(__omnichannelSubscriptionItemJson); + OmnichannelSubscriptionItem.fromJson(__omnichannelSubscriptionItemObj); } - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - obj.customer = Customer.fromJson(__customerJson); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + obj.customer = Customer.fromJson(__customerObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/OmnichannelSubscriptionItemCancelledEvent.java b/src/main/java/com/chargebee/v4/models/event/OmnichannelSubscriptionItemCancelledEvent.java index f0c7cbba..ad4b6830 100644 --- a/src/main/java/com/chargebee/v4/models/event/OmnichannelSubscriptionItemCancelledEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/OmnichannelSubscriptionItemCancelledEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.customer.Customer; @@ -59,25 +60,29 @@ public Content getContent() { } public static OmnichannelSubscriptionItemCancelledEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static OmnichannelSubscriptionItemCancelledEvent fromJson(JsonObject jsonObj) { OmnichannelSubscriptionItemCancelledEvent obj = new OmnichannelSubscriptionItemCancelledEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -147,24 +152,29 @@ public Customer getCustomer() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __omnichannelSubscriptionJson = JsonUtil.getObject(json, "omnichannel_subscription"); - if (__omnichannelSubscriptionJson != null) { + JsonObject __omnichannelSubscriptionObj = + JsonUtil.getJsonObject(jsonObj, "omnichannel_subscription"); + if (__omnichannelSubscriptionObj != null) { obj.omnichannelSubscription = - OmnichannelSubscription.fromJson(__omnichannelSubscriptionJson); + OmnichannelSubscription.fromJson(__omnichannelSubscriptionObj); } - String __omnichannelSubscriptionItemJson = - JsonUtil.getObject(json, "omnichannel_subscription_item"); - if (__omnichannelSubscriptionItemJson != null) { + JsonObject __omnichannelSubscriptionItemObj = + JsonUtil.getJsonObject(jsonObj, "omnichannel_subscription_item"); + if (__omnichannelSubscriptionItemObj != null) { obj.omnichannelSubscriptionItem = - OmnichannelSubscriptionItem.fromJson(__omnichannelSubscriptionItemJson); + OmnichannelSubscriptionItem.fromJson(__omnichannelSubscriptionItemObj); } - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - obj.customer = Customer.fromJson(__customerJson); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + obj.customer = Customer.fromJson(__customerObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/OmnichannelSubscriptionItemChangeScheduledEvent.java b/src/main/java/com/chargebee/v4/models/event/OmnichannelSubscriptionItemChangeScheduledEvent.java index 273e7311..3f0ca0e7 100644 --- a/src/main/java/com/chargebee/v4/models/event/OmnichannelSubscriptionItemChangeScheduledEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/OmnichannelSubscriptionItemChangeScheduledEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.customer.Customer; @@ -59,26 +60,30 @@ public Content getContent() { } public static OmnichannelSubscriptionItemChangeScheduledEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static OmnichannelSubscriptionItemChangeScheduledEvent fromJson(JsonObject jsonObj) { OmnichannelSubscriptionItemChangeScheduledEvent obj = new OmnichannelSubscriptionItemChangeScheduledEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -150,26 +155,30 @@ public Customer getCustomer() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __omnichannelSubscriptionItemJson = - JsonUtil.getObject(json, "omnichannel_subscription_item"); - if (__omnichannelSubscriptionItemJson != null) { + JsonObject __omnichannelSubscriptionItemObj = + JsonUtil.getJsonObject(jsonObj, "omnichannel_subscription_item"); + if (__omnichannelSubscriptionItemObj != null) { obj.omnichannelSubscriptionItem = - OmnichannelSubscriptionItem.fromJson(__omnichannelSubscriptionItemJson); + OmnichannelSubscriptionItem.fromJson(__omnichannelSubscriptionItemObj); } - String __omnichannelSubscriptionItemScheduledChangeJson = - JsonUtil.getObject(json, "omnichannel_subscription_item_scheduled_change"); - if (__omnichannelSubscriptionItemScheduledChangeJson != null) { + JsonObject __omnichannelSubscriptionItemScheduledChangeObj = + JsonUtil.getJsonObject(jsonObj, "omnichannel_subscription_item_scheduled_change"); + if (__omnichannelSubscriptionItemScheduledChangeObj != null) { obj.omnichannelSubscriptionItemScheduledChange = OmnichannelSubscriptionItemScheduledChange.fromJson( - __omnichannelSubscriptionItemScheduledChangeJson); + __omnichannelSubscriptionItemScheduledChangeObj); } - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - obj.customer = Customer.fromJson(__customerJson); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + obj.customer = Customer.fromJson(__customerObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/OmnichannelSubscriptionItemChangedEvent.java b/src/main/java/com/chargebee/v4/models/event/OmnichannelSubscriptionItemChangedEvent.java index eef252ee..c5fd0f35 100644 --- a/src/main/java/com/chargebee/v4/models/event/OmnichannelSubscriptionItemChangedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/OmnichannelSubscriptionItemChangedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.customer.Customer; @@ -63,25 +64,29 @@ public Content getContent() { } public static OmnichannelSubscriptionItemChangedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static OmnichannelSubscriptionItemChangedEvent fromJson(JsonObject jsonObj) { OmnichannelSubscriptionItemChangedEvent obj = new OmnichannelSubscriptionItemChangedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -162,37 +167,43 @@ public Customer getCustomer() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __omnichannelSubscriptionItemJson = - JsonUtil.getObject(json, "omnichannel_subscription_item"); - if (__omnichannelSubscriptionItemJson != null) { + JsonObject __omnichannelSubscriptionItemObj = + JsonUtil.getJsonObject(jsonObj, "omnichannel_subscription_item"); + if (__omnichannelSubscriptionItemObj != null) { obj.omnichannelSubscriptionItem = - OmnichannelSubscriptionItem.fromJson(__omnichannelSubscriptionItemJson); + OmnichannelSubscriptionItem.fromJson(__omnichannelSubscriptionItemObj); } - String __omnichannelSubscriptionJson = JsonUtil.getObject(json, "omnichannel_subscription"); - if (__omnichannelSubscriptionJson != null) { + JsonObject __omnichannelSubscriptionObj = + JsonUtil.getJsonObject(jsonObj, "omnichannel_subscription"); + if (__omnichannelSubscriptionObj != null) { obj.omnichannelSubscription = - OmnichannelSubscription.fromJson(__omnichannelSubscriptionJson); + OmnichannelSubscription.fromJson(__omnichannelSubscriptionObj); } - String __omnichannelTransactionJson = JsonUtil.getObject(json, "omnichannel_transaction"); - if (__omnichannelTransactionJson != null) { - obj.omnichannelTransaction = OmnichannelTransaction.fromJson(__omnichannelTransactionJson); + JsonObject __omnichannelTransactionObj = + JsonUtil.getJsonObject(jsonObj, "omnichannel_transaction"); + if (__omnichannelTransactionObj != null) { + obj.omnichannelTransaction = OmnichannelTransaction.fromJson(__omnichannelTransactionObj); } - String __omnichannelSubscriptionItemScheduledChangeJson = - JsonUtil.getObject(json, "omnichannel_subscription_item_scheduled_change"); - if (__omnichannelSubscriptionItemScheduledChangeJson != null) { + JsonObject __omnichannelSubscriptionItemScheduledChangeObj = + JsonUtil.getJsonObject(jsonObj, "omnichannel_subscription_item_scheduled_change"); + if (__omnichannelSubscriptionItemScheduledChangeObj != null) { obj.omnichannelSubscriptionItemScheduledChange = OmnichannelSubscriptionItemScheduledChange.fromJson( - __omnichannelSubscriptionItemScheduledChangeJson); + __omnichannelSubscriptionItemScheduledChangeObj); } - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - obj.customer = Customer.fromJson(__customerJson); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + obj.customer = Customer.fromJson(__customerObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/OmnichannelSubscriptionItemDowngradeScheduledEvent.java b/src/main/java/com/chargebee/v4/models/event/OmnichannelSubscriptionItemDowngradeScheduledEvent.java index 086f024b..94bc6ed2 100644 --- a/src/main/java/com/chargebee/v4/models/event/OmnichannelSubscriptionItemDowngradeScheduledEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/OmnichannelSubscriptionItemDowngradeScheduledEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.customer.Customer; @@ -59,26 +60,30 @@ public Content getContent() { } public static OmnichannelSubscriptionItemDowngradeScheduledEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static OmnichannelSubscriptionItemDowngradeScheduledEvent fromJson(JsonObject jsonObj) { OmnichannelSubscriptionItemDowngradeScheduledEvent obj = new OmnichannelSubscriptionItemDowngradeScheduledEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -149,24 +154,29 @@ public Customer getCustomer() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __omnichannelSubscriptionJson = JsonUtil.getObject(json, "omnichannel_subscription"); - if (__omnichannelSubscriptionJson != null) { + JsonObject __omnichannelSubscriptionObj = + JsonUtil.getJsonObject(jsonObj, "omnichannel_subscription"); + if (__omnichannelSubscriptionObj != null) { obj.omnichannelSubscription = - OmnichannelSubscription.fromJson(__omnichannelSubscriptionJson); + OmnichannelSubscription.fromJson(__omnichannelSubscriptionObj); } - String __omnichannelSubscriptionItemJson = - JsonUtil.getObject(json, "omnichannel_subscription_item"); - if (__omnichannelSubscriptionItemJson != null) { + JsonObject __omnichannelSubscriptionItemObj = + JsonUtil.getJsonObject(jsonObj, "omnichannel_subscription_item"); + if (__omnichannelSubscriptionItemObj != null) { obj.omnichannelSubscriptionItem = - OmnichannelSubscriptionItem.fromJson(__omnichannelSubscriptionItemJson); + OmnichannelSubscriptionItem.fromJson(__omnichannelSubscriptionItemObj); } - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - obj.customer = Customer.fromJson(__customerJson); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + obj.customer = Customer.fromJson(__customerObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/OmnichannelSubscriptionItemDowngradedEvent.java b/src/main/java/com/chargebee/v4/models/event/OmnichannelSubscriptionItemDowngradedEvent.java index 343acc0c..254976d0 100644 --- a/src/main/java/com/chargebee/v4/models/event/OmnichannelSubscriptionItemDowngradedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/OmnichannelSubscriptionItemDowngradedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.customer.Customer; @@ -61,26 +62,30 @@ public Content getContent() { } public static OmnichannelSubscriptionItemDowngradedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static OmnichannelSubscriptionItemDowngradedEvent fromJson(JsonObject jsonObj) { OmnichannelSubscriptionItemDowngradedEvent obj = new OmnichannelSubscriptionItemDowngradedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -156,29 +161,35 @@ public Customer getCustomer() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __omnichannelSubscriptionItemJson = - JsonUtil.getObject(json, "omnichannel_subscription_item"); - if (__omnichannelSubscriptionItemJson != null) { + JsonObject __omnichannelSubscriptionItemObj = + JsonUtil.getJsonObject(jsonObj, "omnichannel_subscription_item"); + if (__omnichannelSubscriptionItemObj != null) { obj.omnichannelSubscriptionItem = - OmnichannelSubscriptionItem.fromJson(__omnichannelSubscriptionItemJson); + OmnichannelSubscriptionItem.fromJson(__omnichannelSubscriptionItemObj); } - String __omnichannelSubscriptionJson = JsonUtil.getObject(json, "omnichannel_subscription"); - if (__omnichannelSubscriptionJson != null) { + JsonObject __omnichannelSubscriptionObj = + JsonUtil.getJsonObject(jsonObj, "omnichannel_subscription"); + if (__omnichannelSubscriptionObj != null) { obj.omnichannelSubscription = - OmnichannelSubscription.fromJson(__omnichannelSubscriptionJson); + OmnichannelSubscription.fromJson(__omnichannelSubscriptionObj); } - String __omnichannelTransactionJson = JsonUtil.getObject(json, "omnichannel_transaction"); - if (__omnichannelTransactionJson != null) { - obj.omnichannelTransaction = OmnichannelTransaction.fromJson(__omnichannelTransactionJson); + JsonObject __omnichannelTransactionObj = + JsonUtil.getJsonObject(jsonObj, "omnichannel_transaction"); + if (__omnichannelTransactionObj != null) { + obj.omnichannelTransaction = OmnichannelTransaction.fromJson(__omnichannelTransactionObj); } - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - obj.customer = Customer.fromJson(__customerJson); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + obj.customer = Customer.fromJson(__customerObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/OmnichannelSubscriptionItemDunningExpiredEvent.java b/src/main/java/com/chargebee/v4/models/event/OmnichannelSubscriptionItemDunningExpiredEvent.java index 03f27ea5..df2cf95f 100644 --- a/src/main/java/com/chargebee/v4/models/event/OmnichannelSubscriptionItemDunningExpiredEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/OmnichannelSubscriptionItemDunningExpiredEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.customer.Customer; @@ -59,26 +60,30 @@ public Content getContent() { } public static OmnichannelSubscriptionItemDunningExpiredEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static OmnichannelSubscriptionItemDunningExpiredEvent fromJson(JsonObject jsonObj) { OmnichannelSubscriptionItemDunningExpiredEvent obj = new OmnichannelSubscriptionItemDunningExpiredEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -149,24 +154,29 @@ public Customer getCustomer() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __omnichannelSubscriptionJson = JsonUtil.getObject(json, "omnichannel_subscription"); - if (__omnichannelSubscriptionJson != null) { + JsonObject __omnichannelSubscriptionObj = + JsonUtil.getJsonObject(jsonObj, "omnichannel_subscription"); + if (__omnichannelSubscriptionObj != null) { obj.omnichannelSubscription = - OmnichannelSubscription.fromJson(__omnichannelSubscriptionJson); + OmnichannelSubscription.fromJson(__omnichannelSubscriptionObj); } - String __omnichannelSubscriptionItemJson = - JsonUtil.getObject(json, "omnichannel_subscription_item"); - if (__omnichannelSubscriptionItemJson != null) { + JsonObject __omnichannelSubscriptionItemObj = + JsonUtil.getJsonObject(jsonObj, "omnichannel_subscription_item"); + if (__omnichannelSubscriptionItemObj != null) { obj.omnichannelSubscriptionItem = - OmnichannelSubscriptionItem.fromJson(__omnichannelSubscriptionItemJson); + OmnichannelSubscriptionItem.fromJson(__omnichannelSubscriptionItemObj); } - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - obj.customer = Customer.fromJson(__customerJson); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + obj.customer = Customer.fromJson(__customerObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/OmnichannelSubscriptionItemDunningStartedEvent.java b/src/main/java/com/chargebee/v4/models/event/OmnichannelSubscriptionItemDunningStartedEvent.java index 4e417201..cd8a6b73 100644 --- a/src/main/java/com/chargebee/v4/models/event/OmnichannelSubscriptionItemDunningStartedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/OmnichannelSubscriptionItemDunningStartedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.customer.Customer; @@ -59,26 +60,30 @@ public Content getContent() { } public static OmnichannelSubscriptionItemDunningStartedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static OmnichannelSubscriptionItemDunningStartedEvent fromJson(JsonObject jsonObj) { OmnichannelSubscriptionItemDunningStartedEvent obj = new OmnichannelSubscriptionItemDunningStartedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -149,24 +154,29 @@ public Customer getCustomer() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __omnichannelSubscriptionJson = JsonUtil.getObject(json, "omnichannel_subscription"); - if (__omnichannelSubscriptionJson != null) { + JsonObject __omnichannelSubscriptionObj = + JsonUtil.getJsonObject(jsonObj, "omnichannel_subscription"); + if (__omnichannelSubscriptionObj != null) { obj.omnichannelSubscription = - OmnichannelSubscription.fromJson(__omnichannelSubscriptionJson); + OmnichannelSubscription.fromJson(__omnichannelSubscriptionObj); } - String __omnichannelSubscriptionItemJson = - JsonUtil.getObject(json, "omnichannel_subscription_item"); - if (__omnichannelSubscriptionItemJson != null) { + JsonObject __omnichannelSubscriptionItemObj = + JsonUtil.getJsonObject(jsonObj, "omnichannel_subscription_item"); + if (__omnichannelSubscriptionItemObj != null) { obj.omnichannelSubscriptionItem = - OmnichannelSubscriptionItem.fromJson(__omnichannelSubscriptionItemJson); + OmnichannelSubscriptionItem.fromJson(__omnichannelSubscriptionItemObj); } - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - obj.customer = Customer.fromJson(__customerJson); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + obj.customer = Customer.fromJson(__customerObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/OmnichannelSubscriptionItemExpiredEvent.java b/src/main/java/com/chargebee/v4/models/event/OmnichannelSubscriptionItemExpiredEvent.java index 798ebef5..ed426061 100644 --- a/src/main/java/com/chargebee/v4/models/event/OmnichannelSubscriptionItemExpiredEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/OmnichannelSubscriptionItemExpiredEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.customer.Customer; @@ -59,25 +60,29 @@ public Content getContent() { } public static OmnichannelSubscriptionItemExpiredEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static OmnichannelSubscriptionItemExpiredEvent fromJson(JsonObject jsonObj) { OmnichannelSubscriptionItemExpiredEvent obj = new OmnichannelSubscriptionItemExpiredEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -147,24 +152,29 @@ public Customer getCustomer() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __omnichannelSubscriptionJson = JsonUtil.getObject(json, "omnichannel_subscription"); - if (__omnichannelSubscriptionJson != null) { + JsonObject __omnichannelSubscriptionObj = + JsonUtil.getJsonObject(jsonObj, "omnichannel_subscription"); + if (__omnichannelSubscriptionObj != null) { obj.omnichannelSubscription = - OmnichannelSubscription.fromJson(__omnichannelSubscriptionJson); + OmnichannelSubscription.fromJson(__omnichannelSubscriptionObj); } - String __omnichannelSubscriptionItemJson = - JsonUtil.getObject(json, "omnichannel_subscription_item"); - if (__omnichannelSubscriptionItemJson != null) { + JsonObject __omnichannelSubscriptionItemObj = + JsonUtil.getJsonObject(jsonObj, "omnichannel_subscription_item"); + if (__omnichannelSubscriptionItemObj != null) { obj.omnichannelSubscriptionItem = - OmnichannelSubscriptionItem.fromJson(__omnichannelSubscriptionItemJson); + OmnichannelSubscriptionItem.fromJson(__omnichannelSubscriptionItemObj); } - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - obj.customer = Customer.fromJson(__customerJson); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + obj.customer = Customer.fromJson(__customerObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/OmnichannelSubscriptionItemGracePeriodExpiredEvent.java b/src/main/java/com/chargebee/v4/models/event/OmnichannelSubscriptionItemGracePeriodExpiredEvent.java index a8936283..72869569 100644 --- a/src/main/java/com/chargebee/v4/models/event/OmnichannelSubscriptionItemGracePeriodExpiredEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/OmnichannelSubscriptionItemGracePeriodExpiredEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.customer.Customer; @@ -59,26 +60,30 @@ public Content getContent() { } public static OmnichannelSubscriptionItemGracePeriodExpiredEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static OmnichannelSubscriptionItemGracePeriodExpiredEvent fromJson(JsonObject jsonObj) { OmnichannelSubscriptionItemGracePeriodExpiredEvent obj = new OmnichannelSubscriptionItemGracePeriodExpiredEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -149,24 +154,29 @@ public Customer getCustomer() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __omnichannelSubscriptionJson = JsonUtil.getObject(json, "omnichannel_subscription"); - if (__omnichannelSubscriptionJson != null) { + JsonObject __omnichannelSubscriptionObj = + JsonUtil.getJsonObject(jsonObj, "omnichannel_subscription"); + if (__omnichannelSubscriptionObj != null) { obj.omnichannelSubscription = - OmnichannelSubscription.fromJson(__omnichannelSubscriptionJson); + OmnichannelSubscription.fromJson(__omnichannelSubscriptionObj); } - String __omnichannelSubscriptionItemJson = - JsonUtil.getObject(json, "omnichannel_subscription_item"); - if (__omnichannelSubscriptionItemJson != null) { + JsonObject __omnichannelSubscriptionItemObj = + JsonUtil.getJsonObject(jsonObj, "omnichannel_subscription_item"); + if (__omnichannelSubscriptionItemObj != null) { obj.omnichannelSubscriptionItem = - OmnichannelSubscriptionItem.fromJson(__omnichannelSubscriptionItemJson); + OmnichannelSubscriptionItem.fromJson(__omnichannelSubscriptionItemObj); } - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - obj.customer = Customer.fromJson(__customerJson); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + obj.customer = Customer.fromJson(__customerObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/OmnichannelSubscriptionItemGracePeriodStartedEvent.java b/src/main/java/com/chargebee/v4/models/event/OmnichannelSubscriptionItemGracePeriodStartedEvent.java index fec4a58b..6a497450 100644 --- a/src/main/java/com/chargebee/v4/models/event/OmnichannelSubscriptionItemGracePeriodStartedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/OmnichannelSubscriptionItemGracePeriodStartedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.customer.Customer; @@ -59,26 +60,30 @@ public Content getContent() { } public static OmnichannelSubscriptionItemGracePeriodStartedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static OmnichannelSubscriptionItemGracePeriodStartedEvent fromJson(JsonObject jsonObj) { OmnichannelSubscriptionItemGracePeriodStartedEvent obj = new OmnichannelSubscriptionItemGracePeriodStartedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -149,24 +154,29 @@ public Customer getCustomer() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __omnichannelSubscriptionJson = JsonUtil.getObject(json, "omnichannel_subscription"); - if (__omnichannelSubscriptionJson != null) { + JsonObject __omnichannelSubscriptionObj = + JsonUtil.getJsonObject(jsonObj, "omnichannel_subscription"); + if (__omnichannelSubscriptionObj != null) { obj.omnichannelSubscription = - OmnichannelSubscription.fromJson(__omnichannelSubscriptionJson); + OmnichannelSubscription.fromJson(__omnichannelSubscriptionObj); } - String __omnichannelSubscriptionItemJson = - JsonUtil.getObject(json, "omnichannel_subscription_item"); - if (__omnichannelSubscriptionItemJson != null) { + JsonObject __omnichannelSubscriptionItemObj = + JsonUtil.getJsonObject(jsonObj, "omnichannel_subscription_item"); + if (__omnichannelSubscriptionItemObj != null) { obj.omnichannelSubscriptionItem = - OmnichannelSubscriptionItem.fromJson(__omnichannelSubscriptionItemJson); + OmnichannelSubscriptionItem.fromJson(__omnichannelSubscriptionItemObj); } - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - obj.customer = Customer.fromJson(__customerJson); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + obj.customer = Customer.fromJson(__customerObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/OmnichannelSubscriptionItemPauseScheduledEvent.java b/src/main/java/com/chargebee/v4/models/event/OmnichannelSubscriptionItemPauseScheduledEvent.java index 8159c009..c834266b 100644 --- a/src/main/java/com/chargebee/v4/models/event/OmnichannelSubscriptionItemPauseScheduledEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/OmnichannelSubscriptionItemPauseScheduledEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.customer.Customer; @@ -59,26 +60,30 @@ public Content getContent() { } public static OmnichannelSubscriptionItemPauseScheduledEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static OmnichannelSubscriptionItemPauseScheduledEvent fromJson(JsonObject jsonObj) { OmnichannelSubscriptionItemPauseScheduledEvent obj = new OmnichannelSubscriptionItemPauseScheduledEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -150,26 +155,30 @@ public Customer getCustomer() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __omnichannelSubscriptionItemJson = - JsonUtil.getObject(json, "omnichannel_subscription_item"); - if (__omnichannelSubscriptionItemJson != null) { + JsonObject __omnichannelSubscriptionItemObj = + JsonUtil.getJsonObject(jsonObj, "omnichannel_subscription_item"); + if (__omnichannelSubscriptionItemObj != null) { obj.omnichannelSubscriptionItem = - OmnichannelSubscriptionItem.fromJson(__omnichannelSubscriptionItemJson); + OmnichannelSubscriptionItem.fromJson(__omnichannelSubscriptionItemObj); } - String __omnichannelSubscriptionItemScheduledChangeJson = - JsonUtil.getObject(json, "omnichannel_subscription_item_scheduled_change"); - if (__omnichannelSubscriptionItemScheduledChangeJson != null) { + JsonObject __omnichannelSubscriptionItemScheduledChangeObj = + JsonUtil.getJsonObject(jsonObj, "omnichannel_subscription_item_scheduled_change"); + if (__omnichannelSubscriptionItemScheduledChangeObj != null) { obj.omnichannelSubscriptionItemScheduledChange = OmnichannelSubscriptionItemScheduledChange.fromJson( - __omnichannelSubscriptionItemScheduledChangeJson); + __omnichannelSubscriptionItemScheduledChangeObj); } - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - obj.customer = Customer.fromJson(__customerJson); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + obj.customer = Customer.fromJson(__customerObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/OmnichannelSubscriptionItemPausedEvent.java b/src/main/java/com/chargebee/v4/models/event/OmnichannelSubscriptionItemPausedEvent.java index 68410ff9..9c30df72 100644 --- a/src/main/java/com/chargebee/v4/models/event/OmnichannelSubscriptionItemPausedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/OmnichannelSubscriptionItemPausedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.customer.Customer; @@ -59,25 +60,29 @@ public Content getContent() { } public static OmnichannelSubscriptionItemPausedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static OmnichannelSubscriptionItemPausedEvent fromJson(JsonObject jsonObj) { OmnichannelSubscriptionItemPausedEvent obj = new OmnichannelSubscriptionItemPausedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -147,24 +152,29 @@ public Customer getCustomer() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __omnichannelSubscriptionJson = JsonUtil.getObject(json, "omnichannel_subscription"); - if (__omnichannelSubscriptionJson != null) { + JsonObject __omnichannelSubscriptionObj = + JsonUtil.getJsonObject(jsonObj, "omnichannel_subscription"); + if (__omnichannelSubscriptionObj != null) { obj.omnichannelSubscription = - OmnichannelSubscription.fromJson(__omnichannelSubscriptionJson); + OmnichannelSubscription.fromJson(__omnichannelSubscriptionObj); } - String __omnichannelSubscriptionItemJson = - JsonUtil.getObject(json, "omnichannel_subscription_item"); - if (__omnichannelSubscriptionItemJson != null) { + JsonObject __omnichannelSubscriptionItemObj = + JsonUtil.getJsonObject(jsonObj, "omnichannel_subscription_item"); + if (__omnichannelSubscriptionItemObj != null) { obj.omnichannelSubscriptionItem = - OmnichannelSubscriptionItem.fromJson(__omnichannelSubscriptionItemJson); + OmnichannelSubscriptionItem.fromJson(__omnichannelSubscriptionItemObj); } - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - obj.customer = Customer.fromJson(__customerJson); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + obj.customer = Customer.fromJson(__customerObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/OmnichannelSubscriptionItemReactivatedEvent.java b/src/main/java/com/chargebee/v4/models/event/OmnichannelSubscriptionItemReactivatedEvent.java index 9c023d41..b4258adb 100644 --- a/src/main/java/com/chargebee/v4/models/event/OmnichannelSubscriptionItemReactivatedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/OmnichannelSubscriptionItemReactivatedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.customer.Customer; @@ -59,26 +60,30 @@ public Content getContent() { } public static OmnichannelSubscriptionItemReactivatedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static OmnichannelSubscriptionItemReactivatedEvent fromJson(JsonObject jsonObj) { OmnichannelSubscriptionItemReactivatedEvent obj = new OmnichannelSubscriptionItemReactivatedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -149,24 +154,29 @@ public Customer getCustomer() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __omnichannelSubscriptionJson = JsonUtil.getObject(json, "omnichannel_subscription"); - if (__omnichannelSubscriptionJson != null) { + JsonObject __omnichannelSubscriptionObj = + JsonUtil.getJsonObject(jsonObj, "omnichannel_subscription"); + if (__omnichannelSubscriptionObj != null) { obj.omnichannelSubscription = - OmnichannelSubscription.fromJson(__omnichannelSubscriptionJson); + OmnichannelSubscription.fromJson(__omnichannelSubscriptionObj); } - String __omnichannelSubscriptionItemJson = - JsonUtil.getObject(json, "omnichannel_subscription_item"); - if (__omnichannelSubscriptionItemJson != null) { + JsonObject __omnichannelSubscriptionItemObj = + JsonUtil.getJsonObject(jsonObj, "omnichannel_subscription_item"); + if (__omnichannelSubscriptionItemObj != null) { obj.omnichannelSubscriptionItem = - OmnichannelSubscriptionItem.fromJson(__omnichannelSubscriptionItemJson); + OmnichannelSubscriptionItem.fromJson(__omnichannelSubscriptionItemObj); } - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - obj.customer = Customer.fromJson(__customerJson); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + obj.customer = Customer.fromJson(__customerObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/OmnichannelSubscriptionItemRenewedEvent.java b/src/main/java/com/chargebee/v4/models/event/OmnichannelSubscriptionItemRenewedEvent.java index 3ffc9ccc..831c8956 100644 --- a/src/main/java/com/chargebee/v4/models/event/OmnichannelSubscriptionItemRenewedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/OmnichannelSubscriptionItemRenewedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.customer.Customer; @@ -63,25 +64,29 @@ public Content getContent() { } public static OmnichannelSubscriptionItemRenewedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static OmnichannelSubscriptionItemRenewedEvent fromJson(JsonObject jsonObj) { OmnichannelSubscriptionItemRenewedEvent obj = new OmnichannelSubscriptionItemRenewedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -162,37 +167,43 @@ public Customer getCustomer() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __omnichannelSubscriptionItemJson = - JsonUtil.getObject(json, "omnichannel_subscription_item"); - if (__omnichannelSubscriptionItemJson != null) { + JsonObject __omnichannelSubscriptionItemObj = + JsonUtil.getJsonObject(jsonObj, "omnichannel_subscription_item"); + if (__omnichannelSubscriptionItemObj != null) { obj.omnichannelSubscriptionItem = - OmnichannelSubscriptionItem.fromJson(__omnichannelSubscriptionItemJson); + OmnichannelSubscriptionItem.fromJson(__omnichannelSubscriptionItemObj); } - String __omnichannelSubscriptionJson = JsonUtil.getObject(json, "omnichannel_subscription"); - if (__omnichannelSubscriptionJson != null) { + JsonObject __omnichannelSubscriptionObj = + JsonUtil.getJsonObject(jsonObj, "omnichannel_subscription"); + if (__omnichannelSubscriptionObj != null) { obj.omnichannelSubscription = - OmnichannelSubscription.fromJson(__omnichannelSubscriptionJson); + OmnichannelSubscription.fromJson(__omnichannelSubscriptionObj); } - String __omnichannelTransactionJson = JsonUtil.getObject(json, "omnichannel_transaction"); - if (__omnichannelTransactionJson != null) { - obj.omnichannelTransaction = OmnichannelTransaction.fromJson(__omnichannelTransactionJson); + JsonObject __omnichannelTransactionObj = + JsonUtil.getJsonObject(jsonObj, "omnichannel_transaction"); + if (__omnichannelTransactionObj != null) { + obj.omnichannelTransaction = OmnichannelTransaction.fromJson(__omnichannelTransactionObj); } - String __omnichannelSubscriptionItemScheduledChangeJson = - JsonUtil.getObject(json, "omnichannel_subscription_item_scheduled_change"); - if (__omnichannelSubscriptionItemScheduledChangeJson != null) { + JsonObject __omnichannelSubscriptionItemScheduledChangeObj = + JsonUtil.getJsonObject(jsonObj, "omnichannel_subscription_item_scheduled_change"); + if (__omnichannelSubscriptionItemScheduledChangeObj != null) { obj.omnichannelSubscriptionItemScheduledChange = OmnichannelSubscriptionItemScheduledChange.fromJson( - __omnichannelSubscriptionItemScheduledChangeJson); + __omnichannelSubscriptionItemScheduledChangeObj); } - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - obj.customer = Customer.fromJson(__customerJson); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + obj.customer = Customer.fromJson(__customerObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/OmnichannelSubscriptionItemResubscribedEvent.java b/src/main/java/com/chargebee/v4/models/event/OmnichannelSubscriptionItemResubscribedEvent.java index f357287d..f5ce5806 100644 --- a/src/main/java/com/chargebee/v4/models/event/OmnichannelSubscriptionItemResubscribedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/OmnichannelSubscriptionItemResubscribedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.customer.Customer; @@ -63,26 +64,30 @@ public Content getContent() { } public static OmnichannelSubscriptionItemResubscribedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static OmnichannelSubscriptionItemResubscribedEvent fromJson(JsonObject jsonObj) { OmnichannelSubscriptionItemResubscribedEvent obj = new OmnichannelSubscriptionItemResubscribedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -164,37 +169,43 @@ public Customer getCustomer() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __omnichannelSubscriptionItemJson = - JsonUtil.getObject(json, "omnichannel_subscription_item"); - if (__omnichannelSubscriptionItemJson != null) { + JsonObject __omnichannelSubscriptionItemObj = + JsonUtil.getJsonObject(jsonObj, "omnichannel_subscription_item"); + if (__omnichannelSubscriptionItemObj != null) { obj.omnichannelSubscriptionItem = - OmnichannelSubscriptionItem.fromJson(__omnichannelSubscriptionItemJson); + OmnichannelSubscriptionItem.fromJson(__omnichannelSubscriptionItemObj); } - String __omnichannelSubscriptionJson = JsonUtil.getObject(json, "omnichannel_subscription"); - if (__omnichannelSubscriptionJson != null) { + JsonObject __omnichannelSubscriptionObj = + JsonUtil.getJsonObject(jsonObj, "omnichannel_subscription"); + if (__omnichannelSubscriptionObj != null) { obj.omnichannelSubscription = - OmnichannelSubscription.fromJson(__omnichannelSubscriptionJson); + OmnichannelSubscription.fromJson(__omnichannelSubscriptionObj); } - String __omnichannelTransactionJson = JsonUtil.getObject(json, "omnichannel_transaction"); - if (__omnichannelTransactionJson != null) { - obj.omnichannelTransaction = OmnichannelTransaction.fromJson(__omnichannelTransactionJson); + JsonObject __omnichannelTransactionObj = + JsonUtil.getJsonObject(jsonObj, "omnichannel_transaction"); + if (__omnichannelTransactionObj != null) { + obj.omnichannelTransaction = OmnichannelTransaction.fromJson(__omnichannelTransactionObj); } - String __omnichannelSubscriptionItemScheduledChangeJson = - JsonUtil.getObject(json, "omnichannel_subscription_item_scheduled_change"); - if (__omnichannelSubscriptionItemScheduledChangeJson != null) { + JsonObject __omnichannelSubscriptionItemScheduledChangeObj = + JsonUtil.getJsonObject(jsonObj, "omnichannel_subscription_item_scheduled_change"); + if (__omnichannelSubscriptionItemScheduledChangeObj != null) { obj.omnichannelSubscriptionItemScheduledChange = OmnichannelSubscriptionItemScheduledChange.fromJson( - __omnichannelSubscriptionItemScheduledChangeJson); + __omnichannelSubscriptionItemScheduledChangeObj); } - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - obj.customer = Customer.fromJson(__customerJson); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + obj.customer = Customer.fromJson(__customerObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/OmnichannelSubscriptionItemResumedEvent.java b/src/main/java/com/chargebee/v4/models/event/OmnichannelSubscriptionItemResumedEvent.java index a3897df4..49d4e27e 100644 --- a/src/main/java/com/chargebee/v4/models/event/OmnichannelSubscriptionItemResumedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/OmnichannelSubscriptionItemResumedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.customer.Customer; @@ -59,25 +60,29 @@ public Content getContent() { } public static OmnichannelSubscriptionItemResumedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static OmnichannelSubscriptionItemResumedEvent fromJson(JsonObject jsonObj) { OmnichannelSubscriptionItemResumedEvent obj = new OmnichannelSubscriptionItemResumedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -147,24 +152,29 @@ public Customer getCustomer() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __omnichannelSubscriptionJson = JsonUtil.getObject(json, "omnichannel_subscription"); - if (__omnichannelSubscriptionJson != null) { + JsonObject __omnichannelSubscriptionObj = + JsonUtil.getJsonObject(jsonObj, "omnichannel_subscription"); + if (__omnichannelSubscriptionObj != null) { obj.omnichannelSubscription = - OmnichannelSubscription.fromJson(__omnichannelSubscriptionJson); + OmnichannelSubscription.fromJson(__omnichannelSubscriptionObj); } - String __omnichannelSubscriptionItemJson = - JsonUtil.getObject(json, "omnichannel_subscription_item"); - if (__omnichannelSubscriptionItemJson != null) { + JsonObject __omnichannelSubscriptionItemObj = + JsonUtil.getJsonObject(jsonObj, "omnichannel_subscription_item"); + if (__omnichannelSubscriptionItemObj != null) { obj.omnichannelSubscriptionItem = - OmnichannelSubscriptionItem.fromJson(__omnichannelSubscriptionItemJson); + OmnichannelSubscriptionItem.fromJson(__omnichannelSubscriptionItemObj); } - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - obj.customer = Customer.fromJson(__customerJson); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + obj.customer = Customer.fromJson(__customerObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/OmnichannelSubscriptionItemScheduledCancellationRemovedEvent.java b/src/main/java/com/chargebee/v4/models/event/OmnichannelSubscriptionItemScheduledCancellationRemovedEvent.java index b6a10db8..0f603c3e 100644 --- a/src/main/java/com/chargebee/v4/models/event/OmnichannelSubscriptionItemScheduledCancellationRemovedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/OmnichannelSubscriptionItemScheduledCancellationRemovedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.customer.Customer; @@ -59,26 +60,31 @@ public Content getContent() { } public static OmnichannelSubscriptionItemScheduledCancellationRemovedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static OmnichannelSubscriptionItemScheduledCancellationRemovedEvent fromJson( + JsonObject jsonObj) { OmnichannelSubscriptionItemScheduledCancellationRemovedEvent obj = new OmnichannelSubscriptionItemScheduledCancellationRemovedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -149,24 +155,29 @@ public Customer getCustomer() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __omnichannelSubscriptionJson = JsonUtil.getObject(json, "omnichannel_subscription"); - if (__omnichannelSubscriptionJson != null) { + JsonObject __omnichannelSubscriptionObj = + JsonUtil.getJsonObject(jsonObj, "omnichannel_subscription"); + if (__omnichannelSubscriptionObj != null) { obj.omnichannelSubscription = - OmnichannelSubscription.fromJson(__omnichannelSubscriptionJson); + OmnichannelSubscription.fromJson(__omnichannelSubscriptionObj); } - String __omnichannelSubscriptionItemJson = - JsonUtil.getObject(json, "omnichannel_subscription_item"); - if (__omnichannelSubscriptionItemJson != null) { + JsonObject __omnichannelSubscriptionItemObj = + JsonUtil.getJsonObject(jsonObj, "omnichannel_subscription_item"); + if (__omnichannelSubscriptionItemObj != null) { obj.omnichannelSubscriptionItem = - OmnichannelSubscriptionItem.fromJson(__omnichannelSubscriptionItemJson); + OmnichannelSubscriptionItem.fromJson(__omnichannelSubscriptionItemObj); } - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - obj.customer = Customer.fromJson(__customerJson); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + obj.customer = Customer.fromJson(__customerObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/OmnichannelSubscriptionItemScheduledChangeRemovedEvent.java b/src/main/java/com/chargebee/v4/models/event/OmnichannelSubscriptionItemScheduledChangeRemovedEvent.java index 3316e7f8..2c4574fe 100644 --- a/src/main/java/com/chargebee/v4/models/event/OmnichannelSubscriptionItemScheduledChangeRemovedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/OmnichannelSubscriptionItemScheduledChangeRemovedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.customer.Customer; @@ -59,26 +60,31 @@ public Content getContent() { } public static OmnichannelSubscriptionItemScheduledChangeRemovedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static OmnichannelSubscriptionItemScheduledChangeRemovedEvent fromJson( + JsonObject jsonObj) { OmnichannelSubscriptionItemScheduledChangeRemovedEvent obj = new OmnichannelSubscriptionItemScheduledChangeRemovedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -150,26 +156,30 @@ public Customer getCustomer() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __omnichannelSubscriptionItemJson = - JsonUtil.getObject(json, "omnichannel_subscription_item"); - if (__omnichannelSubscriptionItemJson != null) { + JsonObject __omnichannelSubscriptionItemObj = + JsonUtil.getJsonObject(jsonObj, "omnichannel_subscription_item"); + if (__omnichannelSubscriptionItemObj != null) { obj.omnichannelSubscriptionItem = - OmnichannelSubscriptionItem.fromJson(__omnichannelSubscriptionItemJson); + OmnichannelSubscriptionItem.fromJson(__omnichannelSubscriptionItemObj); } - String __omnichannelSubscriptionItemScheduledChangeJson = - JsonUtil.getObject(json, "omnichannel_subscription_item_scheduled_change"); - if (__omnichannelSubscriptionItemScheduledChangeJson != null) { + JsonObject __omnichannelSubscriptionItemScheduledChangeObj = + JsonUtil.getJsonObject(jsonObj, "omnichannel_subscription_item_scheduled_change"); + if (__omnichannelSubscriptionItemScheduledChangeObj != null) { obj.omnichannelSubscriptionItemScheduledChange = OmnichannelSubscriptionItemScheduledChange.fromJson( - __omnichannelSubscriptionItemScheduledChangeJson); + __omnichannelSubscriptionItemScheduledChangeObj); } - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - obj.customer = Customer.fromJson(__customerJson); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + obj.customer = Customer.fromJson(__customerObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/OmnichannelSubscriptionItemScheduledDowngradeRemovedEvent.java b/src/main/java/com/chargebee/v4/models/event/OmnichannelSubscriptionItemScheduledDowngradeRemovedEvent.java index 1e768f27..a4c82192 100644 --- a/src/main/java/com/chargebee/v4/models/event/OmnichannelSubscriptionItemScheduledDowngradeRemovedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/OmnichannelSubscriptionItemScheduledDowngradeRemovedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.customer.Customer; @@ -59,26 +60,31 @@ public Content getContent() { } public static OmnichannelSubscriptionItemScheduledDowngradeRemovedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static OmnichannelSubscriptionItemScheduledDowngradeRemovedEvent fromJson( + JsonObject jsonObj) { OmnichannelSubscriptionItemScheduledDowngradeRemovedEvent obj = new OmnichannelSubscriptionItemScheduledDowngradeRemovedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -149,24 +155,29 @@ public Customer getCustomer() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __omnichannelSubscriptionJson = JsonUtil.getObject(json, "omnichannel_subscription"); - if (__omnichannelSubscriptionJson != null) { + JsonObject __omnichannelSubscriptionObj = + JsonUtil.getJsonObject(jsonObj, "omnichannel_subscription"); + if (__omnichannelSubscriptionObj != null) { obj.omnichannelSubscription = - OmnichannelSubscription.fromJson(__omnichannelSubscriptionJson); + OmnichannelSubscription.fromJson(__omnichannelSubscriptionObj); } - String __omnichannelSubscriptionItemJson = - JsonUtil.getObject(json, "omnichannel_subscription_item"); - if (__omnichannelSubscriptionItemJson != null) { + JsonObject __omnichannelSubscriptionItemObj = + JsonUtil.getJsonObject(jsonObj, "omnichannel_subscription_item"); + if (__omnichannelSubscriptionItemObj != null) { obj.omnichannelSubscriptionItem = - OmnichannelSubscriptionItem.fromJson(__omnichannelSubscriptionItemJson); + OmnichannelSubscriptionItem.fromJson(__omnichannelSubscriptionItemObj); } - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - obj.customer = Customer.fromJson(__customerJson); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + obj.customer = Customer.fromJson(__customerObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/OmnichannelSubscriptionItemUpgradedEvent.java b/src/main/java/com/chargebee/v4/models/event/OmnichannelSubscriptionItemUpgradedEvent.java index f7b30be7..3fe82f9b 100644 --- a/src/main/java/com/chargebee/v4/models/event/OmnichannelSubscriptionItemUpgradedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/OmnichannelSubscriptionItemUpgradedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.customer.Customer; @@ -63,25 +64,29 @@ public Content getContent() { } public static OmnichannelSubscriptionItemUpgradedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static OmnichannelSubscriptionItemUpgradedEvent fromJson(JsonObject jsonObj) { OmnichannelSubscriptionItemUpgradedEvent obj = new OmnichannelSubscriptionItemUpgradedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -162,37 +167,43 @@ public Customer getCustomer() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __omnichannelSubscriptionItemJson = - JsonUtil.getObject(json, "omnichannel_subscription_item"); - if (__omnichannelSubscriptionItemJson != null) { + JsonObject __omnichannelSubscriptionItemObj = + JsonUtil.getJsonObject(jsonObj, "omnichannel_subscription_item"); + if (__omnichannelSubscriptionItemObj != null) { obj.omnichannelSubscriptionItem = - OmnichannelSubscriptionItem.fromJson(__omnichannelSubscriptionItemJson); + OmnichannelSubscriptionItem.fromJson(__omnichannelSubscriptionItemObj); } - String __omnichannelSubscriptionJson = JsonUtil.getObject(json, "omnichannel_subscription"); - if (__omnichannelSubscriptionJson != null) { + JsonObject __omnichannelSubscriptionObj = + JsonUtil.getJsonObject(jsonObj, "omnichannel_subscription"); + if (__omnichannelSubscriptionObj != null) { obj.omnichannelSubscription = - OmnichannelSubscription.fromJson(__omnichannelSubscriptionJson); + OmnichannelSubscription.fromJson(__omnichannelSubscriptionObj); } - String __omnichannelTransactionJson = JsonUtil.getObject(json, "omnichannel_transaction"); - if (__omnichannelTransactionJson != null) { - obj.omnichannelTransaction = OmnichannelTransaction.fromJson(__omnichannelTransactionJson); + JsonObject __omnichannelTransactionObj = + JsonUtil.getJsonObject(jsonObj, "omnichannel_transaction"); + if (__omnichannelTransactionObj != null) { + obj.omnichannelTransaction = OmnichannelTransaction.fromJson(__omnichannelTransactionObj); } - String __omnichannelSubscriptionItemScheduledChangeJson = - JsonUtil.getObject(json, "omnichannel_subscription_item_scheduled_change"); - if (__omnichannelSubscriptionItemScheduledChangeJson != null) { + JsonObject __omnichannelSubscriptionItemScheduledChangeObj = + JsonUtil.getJsonObject(jsonObj, "omnichannel_subscription_item_scheduled_change"); + if (__omnichannelSubscriptionItemScheduledChangeObj != null) { obj.omnichannelSubscriptionItemScheduledChange = OmnichannelSubscriptionItemScheduledChange.fromJson( - __omnichannelSubscriptionItemScheduledChangeJson); + __omnichannelSubscriptionItemScheduledChangeObj); } - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - obj.customer = Customer.fromJson(__customerJson); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + obj.customer = Customer.fromJson(__customerObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/OmnichannelSubscriptionMovedInEvent.java b/src/main/java/com/chargebee/v4/models/event/OmnichannelSubscriptionMovedInEvent.java index f5ab51ca..9b7d2056 100644 --- a/src/main/java/com/chargebee/v4/models/event/OmnichannelSubscriptionMovedInEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/OmnichannelSubscriptionMovedInEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.customer.Customer; @@ -57,25 +58,29 @@ public Content getContent() { } public static OmnichannelSubscriptionMovedInEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static OmnichannelSubscriptionMovedInEvent fromJson(JsonObject jsonObj) { OmnichannelSubscriptionMovedInEvent obj = new OmnichannelSubscriptionMovedInEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -140,17 +145,22 @@ public Customer getCustomer() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __omnichannelSubscriptionJson = JsonUtil.getObject(json, "omnichannel_subscription"); - if (__omnichannelSubscriptionJson != null) { + JsonObject __omnichannelSubscriptionObj = + JsonUtil.getJsonObject(jsonObj, "omnichannel_subscription"); + if (__omnichannelSubscriptionObj != null) { obj.omnichannelSubscription = - OmnichannelSubscription.fromJson(__omnichannelSubscriptionJson); + OmnichannelSubscription.fromJson(__omnichannelSubscriptionObj); } - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - obj.customer = Customer.fromJson(__customerJson); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + obj.customer = Customer.fromJson(__customerObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/OmnichannelTransactionCreatedEvent.java b/src/main/java/com/chargebee/v4/models/event/OmnichannelTransactionCreatedEvent.java index 9a94e278..442e16e2 100644 --- a/src/main/java/com/chargebee/v4/models/event/OmnichannelTransactionCreatedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/OmnichannelTransactionCreatedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.omnichannelTransaction.OmnichannelTransaction; @@ -55,25 +56,29 @@ public Content getContent() { } public static OmnichannelTransactionCreatedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static OmnichannelTransactionCreatedEvent fromJson(JsonObject jsonObj) { OmnichannelTransactionCreatedEvent obj = new OmnichannelTransactionCreatedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -133,11 +138,16 @@ public OmnichannelTransaction getOmnichannelTransaction() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __omnichannelTransactionJson = JsonUtil.getObject(json, "omnichannel_transaction"); - if (__omnichannelTransactionJson != null) { - obj.omnichannelTransaction = OmnichannelTransaction.fromJson(__omnichannelTransactionJson); + JsonObject __omnichannelTransactionObj = + JsonUtil.getJsonObject(jsonObj, "omnichannel_transaction"); + if (__omnichannelTransactionObj != null) { + obj.omnichannelTransaction = OmnichannelTransaction.fromJson(__omnichannelTransactionObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/OrderCancelledEvent.java b/src/main/java/com/chargebee/v4/models/event/OrderCancelledEvent.java index 43f123c0..c8342820 100644 --- a/src/main/java/com/chargebee/v4/models/event/OrderCancelledEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/OrderCancelledEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.order.Order; @@ -55,25 +56,29 @@ public Content getContent() { } public static OrderCancelledEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static OrderCancelledEvent fromJson(JsonObject jsonObj) { OrderCancelledEvent obj = new OrderCancelledEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -133,11 +138,15 @@ public Order getOrder() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __orderJson = JsonUtil.getObject(json, "order"); - if (__orderJson != null) { - obj.order = Order.fromJson(__orderJson); + JsonObject __orderObj = JsonUtil.getJsonObject(jsonObj, "order"); + if (__orderObj != null) { + obj.order = Order.fromJson(__orderObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/OrderCreatedEvent.java b/src/main/java/com/chargebee/v4/models/event/OrderCreatedEvent.java index 6ca0c1d3..cf4ea088 100644 --- a/src/main/java/com/chargebee/v4/models/event/OrderCreatedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/OrderCreatedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.order.Order; @@ -55,25 +56,29 @@ public Content getContent() { } public static OrderCreatedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static OrderCreatedEvent fromJson(JsonObject jsonObj) { OrderCreatedEvent obj = new OrderCreatedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -133,11 +138,15 @@ public Order getOrder() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __orderJson = JsonUtil.getObject(json, "order"); - if (__orderJson != null) { - obj.order = Order.fromJson(__orderJson); + JsonObject __orderObj = JsonUtil.getJsonObject(jsonObj, "order"); + if (__orderObj != null) { + obj.order = Order.fromJson(__orderObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/OrderDeletedEvent.java b/src/main/java/com/chargebee/v4/models/event/OrderDeletedEvent.java index 2e7f175b..9329a865 100644 --- a/src/main/java/com/chargebee/v4/models/event/OrderDeletedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/OrderDeletedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.order.Order; @@ -55,25 +56,29 @@ public Content getContent() { } public static OrderDeletedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static OrderDeletedEvent fromJson(JsonObject jsonObj) { OrderDeletedEvent obj = new OrderDeletedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -133,11 +138,15 @@ public Order getOrder() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __orderJson = JsonUtil.getObject(json, "order"); - if (__orderJson != null) { - obj.order = Order.fromJson(__orderJson); + JsonObject __orderObj = JsonUtil.getJsonObject(jsonObj, "order"); + if (__orderObj != null) { + obj.order = Order.fromJson(__orderObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/OrderDeliveredEvent.java b/src/main/java/com/chargebee/v4/models/event/OrderDeliveredEvent.java index d9c8a627..4b1e814a 100644 --- a/src/main/java/com/chargebee/v4/models/event/OrderDeliveredEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/OrderDeliveredEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.order.Order; @@ -55,25 +56,29 @@ public Content getContent() { } public static OrderDeliveredEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static OrderDeliveredEvent fromJson(JsonObject jsonObj) { OrderDeliveredEvent obj = new OrderDeliveredEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -133,11 +138,15 @@ public Order getOrder() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __orderJson = JsonUtil.getObject(json, "order"); - if (__orderJson != null) { - obj.order = Order.fromJson(__orderJson); + JsonObject __orderObj = JsonUtil.getJsonObject(jsonObj, "order"); + if (__orderObj != null) { + obj.order = Order.fromJson(__orderObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/OrderReadyToProcessEvent.java b/src/main/java/com/chargebee/v4/models/event/OrderReadyToProcessEvent.java index 6a9b0275..245b98a1 100644 --- a/src/main/java/com/chargebee/v4/models/event/OrderReadyToProcessEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/OrderReadyToProcessEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.order.Order; @@ -55,25 +56,29 @@ public Content getContent() { } public static OrderReadyToProcessEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static OrderReadyToProcessEvent fromJson(JsonObject jsonObj) { OrderReadyToProcessEvent obj = new OrderReadyToProcessEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -133,11 +138,15 @@ public Order getOrder() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __orderJson = JsonUtil.getObject(json, "order"); - if (__orderJson != null) { - obj.order = Order.fromJson(__orderJson); + JsonObject __orderObj = JsonUtil.getJsonObject(jsonObj, "order"); + if (__orderObj != null) { + obj.order = Order.fromJson(__orderObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/OrderReadyToShipEvent.java b/src/main/java/com/chargebee/v4/models/event/OrderReadyToShipEvent.java index 76d92add..4e91611f 100644 --- a/src/main/java/com/chargebee/v4/models/event/OrderReadyToShipEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/OrderReadyToShipEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.order.Order; @@ -55,25 +56,29 @@ public Content getContent() { } public static OrderReadyToShipEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static OrderReadyToShipEvent fromJson(JsonObject jsonObj) { OrderReadyToShipEvent obj = new OrderReadyToShipEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -133,11 +138,15 @@ public Order getOrder() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __orderJson = JsonUtil.getObject(json, "order"); - if (__orderJson != null) { - obj.order = Order.fromJson(__orderJson); + JsonObject __orderObj = JsonUtil.getJsonObject(jsonObj, "order"); + if (__orderObj != null) { + obj.order = Order.fromJson(__orderObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/OrderResentEvent.java b/src/main/java/com/chargebee/v4/models/event/OrderResentEvent.java index 4c313227..da8b8395 100644 --- a/src/main/java/com/chargebee/v4/models/event/OrderResentEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/OrderResentEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.order.Order; @@ -55,25 +56,29 @@ public Content getContent() { } public static OrderResentEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static OrderResentEvent fromJson(JsonObject jsonObj) { OrderResentEvent obj = new OrderResentEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -133,11 +138,15 @@ public Order getOrder() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __orderJson = JsonUtil.getObject(json, "order"); - if (__orderJson != null) { - obj.order = Order.fromJson(__orderJson); + JsonObject __orderObj = JsonUtil.getJsonObject(jsonObj, "order"); + if (__orderObj != null) { + obj.order = Order.fromJson(__orderObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/OrderReturnedEvent.java b/src/main/java/com/chargebee/v4/models/event/OrderReturnedEvent.java index 6bc28382..3fb83326 100644 --- a/src/main/java/com/chargebee/v4/models/event/OrderReturnedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/OrderReturnedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.order.Order; @@ -55,25 +56,29 @@ public Content getContent() { } public static OrderReturnedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static OrderReturnedEvent fromJson(JsonObject jsonObj) { OrderReturnedEvent obj = new OrderReturnedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -133,11 +138,15 @@ public Order getOrder() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __orderJson = JsonUtil.getObject(json, "order"); - if (__orderJson != null) { - obj.order = Order.fromJson(__orderJson); + JsonObject __orderObj = JsonUtil.getJsonObject(jsonObj, "order"); + if (__orderObj != null) { + obj.order = Order.fromJson(__orderObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/OrderUpdatedEvent.java b/src/main/java/com/chargebee/v4/models/event/OrderUpdatedEvent.java index 746b1b87..ec8ad1af 100644 --- a/src/main/java/com/chargebee/v4/models/event/OrderUpdatedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/OrderUpdatedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.order.Order; @@ -55,25 +56,29 @@ public Content getContent() { } public static OrderUpdatedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static OrderUpdatedEvent fromJson(JsonObject jsonObj) { OrderUpdatedEvent obj = new OrderUpdatedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -133,11 +138,15 @@ public Order getOrder() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __orderJson = JsonUtil.getObject(json, "order"); - if (__orderJson != null) { - obj.order = Order.fromJson(__orderJson); + JsonObject __orderObj = JsonUtil.getJsonObject(jsonObj, "order"); + if (__orderObj != null) { + obj.order = Order.fromJson(__orderObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/PaymentDueReminderEvent.java b/src/main/java/com/chargebee/v4/models/event/PaymentDueReminderEvent.java index 155312f0..927d8896 100644 --- a/src/main/java/com/chargebee/v4/models/event/PaymentDueReminderEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/PaymentDueReminderEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.customer.Customer; @@ -57,25 +58,29 @@ public Content getContent() { } public static PaymentDueReminderEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static PaymentDueReminderEvent fromJson(JsonObject jsonObj) { PaymentDueReminderEvent obj = new PaymentDueReminderEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -140,16 +145,20 @@ public Invoice getInvoice() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - obj.customer = Customer.fromJson(__customerJson); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + obj.customer = Customer.fromJson(__customerObj); } - String __invoiceJson = JsonUtil.getObject(json, "invoice"); - if (__invoiceJson != null) { - obj.invoice = Invoice.fromJson(__invoiceJson); + JsonObject __invoiceObj = JsonUtil.getJsonObject(jsonObj, "invoice"); + if (__invoiceObj != null) { + obj.invoice = Invoice.fromJson(__invoiceObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/PaymentFailedEvent.java b/src/main/java/com/chargebee/v4/models/event/PaymentFailedEvent.java index b2e366bf..3d215f86 100644 --- a/src/main/java/com/chargebee/v4/models/event/PaymentFailedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/PaymentFailedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.customer.Customer; @@ -63,25 +64,29 @@ public Content getContent() { } public static PaymentFailedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static PaymentFailedEvent fromJson(JsonObject jsonObj) { PaymentFailedEvent obj = new PaymentFailedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -161,31 +166,35 @@ public Card getCard() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __transactionJson = JsonUtil.getObject(json, "transaction"); - if (__transactionJson != null) { - obj.transaction = Transaction.fromJson(__transactionJson); + JsonObject __transactionObj = JsonUtil.getJsonObject(jsonObj, "transaction"); + if (__transactionObj != null) { + obj.transaction = Transaction.fromJson(__transactionObj); } - String __invoiceJson = JsonUtil.getObject(json, "invoice"); - if (__invoiceJson != null) { - obj.invoice = Invoice.fromJson(__invoiceJson); + JsonObject __invoiceObj = JsonUtil.getJsonObject(jsonObj, "invoice"); + if (__invoiceObj != null) { + obj.invoice = Invoice.fromJson(__invoiceObj); } - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - obj.customer = Customer.fromJson(__customerJson); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + obj.customer = Customer.fromJson(__customerObj); } - String __subscriptionJson = JsonUtil.getObject(json, "subscription"); - if (__subscriptionJson != null) { - obj.subscription = Subscription.fromJson(__subscriptionJson); + JsonObject __subscriptionObj = JsonUtil.getJsonObject(jsonObj, "subscription"); + if (__subscriptionObj != null) { + obj.subscription = Subscription.fromJson(__subscriptionObj); } - String __cardJson = JsonUtil.getObject(json, "card"); - if (__cardJson != null) { - obj.card = Card.fromJson(__cardJson); + JsonObject __cardObj = JsonUtil.getJsonObject(jsonObj, "card"); + if (__cardObj != null) { + obj.card = Card.fromJson(__cardObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/PaymentInitiatedEvent.java b/src/main/java/com/chargebee/v4/models/event/PaymentInitiatedEvent.java index 2165208b..3b56ffd2 100644 --- a/src/main/java/com/chargebee/v4/models/event/PaymentInitiatedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/PaymentInitiatedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.customer.Customer; @@ -63,25 +64,29 @@ public Content getContent() { } public static PaymentInitiatedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static PaymentInitiatedEvent fromJson(JsonObject jsonObj) { PaymentInitiatedEvent obj = new PaymentInitiatedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -161,31 +166,35 @@ public Card getCard() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __transactionJson = JsonUtil.getObject(json, "transaction"); - if (__transactionJson != null) { - obj.transaction = Transaction.fromJson(__transactionJson); + JsonObject __transactionObj = JsonUtil.getJsonObject(jsonObj, "transaction"); + if (__transactionObj != null) { + obj.transaction = Transaction.fromJson(__transactionObj); } - String __invoiceJson = JsonUtil.getObject(json, "invoice"); - if (__invoiceJson != null) { - obj.invoice = Invoice.fromJson(__invoiceJson); + JsonObject __invoiceObj = JsonUtil.getJsonObject(jsonObj, "invoice"); + if (__invoiceObj != null) { + obj.invoice = Invoice.fromJson(__invoiceObj); } - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - obj.customer = Customer.fromJson(__customerJson); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + obj.customer = Customer.fromJson(__customerObj); } - String __subscriptionJson = JsonUtil.getObject(json, "subscription"); - if (__subscriptionJson != null) { - obj.subscription = Subscription.fromJson(__subscriptionJson); + JsonObject __subscriptionObj = JsonUtil.getJsonObject(jsonObj, "subscription"); + if (__subscriptionObj != null) { + obj.subscription = Subscription.fromJson(__subscriptionObj); } - String __cardJson = JsonUtil.getObject(json, "card"); - if (__cardJson != null) { - obj.card = Card.fromJson(__cardJson); + JsonObject __cardObj = JsonUtil.getJsonObject(jsonObj, "card"); + if (__cardObj != null) { + obj.card = Card.fromJson(__cardObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/PaymentIntentCreatedEvent.java b/src/main/java/com/chargebee/v4/models/event/PaymentIntentCreatedEvent.java index 444d71ed..727726bd 100644 --- a/src/main/java/com/chargebee/v4/models/event/PaymentIntentCreatedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/PaymentIntentCreatedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.paymentIntent.PaymentIntent; @@ -55,25 +56,29 @@ public Content getContent() { } public static PaymentIntentCreatedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static PaymentIntentCreatedEvent fromJson(JsonObject jsonObj) { PaymentIntentCreatedEvent obj = new PaymentIntentCreatedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -133,11 +138,15 @@ public PaymentIntent getPaymentIntent() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __paymentIntentJson = JsonUtil.getObject(json, "payment_intent"); - if (__paymentIntentJson != null) { - obj.paymentIntent = PaymentIntent.fromJson(__paymentIntentJson); + JsonObject __paymentIntentObj = JsonUtil.getJsonObject(jsonObj, "payment_intent"); + if (__paymentIntentObj != null) { + obj.paymentIntent = PaymentIntent.fromJson(__paymentIntentObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/PaymentIntentUpdatedEvent.java b/src/main/java/com/chargebee/v4/models/event/PaymentIntentUpdatedEvent.java index 60d7bdc7..f5556eaf 100644 --- a/src/main/java/com/chargebee/v4/models/event/PaymentIntentUpdatedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/PaymentIntentUpdatedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.paymentIntent.PaymentIntent; @@ -55,25 +56,29 @@ public Content getContent() { } public static PaymentIntentUpdatedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static PaymentIntentUpdatedEvent fromJson(JsonObject jsonObj) { PaymentIntentUpdatedEvent obj = new PaymentIntentUpdatedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -133,11 +138,15 @@ public PaymentIntent getPaymentIntent() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __paymentIntentJson = JsonUtil.getObject(json, "payment_intent"); - if (__paymentIntentJson != null) { - obj.paymentIntent = PaymentIntent.fromJson(__paymentIntentJson); + JsonObject __paymentIntentObj = JsonUtil.getJsonObject(jsonObj, "payment_intent"); + if (__paymentIntentObj != null) { + obj.paymentIntent = PaymentIntent.fromJson(__paymentIntentObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/PaymentRefundedEvent.java b/src/main/java/com/chargebee/v4/models/event/PaymentRefundedEvent.java index fa9fbdb1..310203cd 100644 --- a/src/main/java/com/chargebee/v4/models/event/PaymentRefundedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/PaymentRefundedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.customer.Customer; @@ -65,25 +66,29 @@ public Content getContent() { } public static PaymentRefundedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static PaymentRefundedEvent fromJson(JsonObject jsonObj) { PaymentRefundedEvent obj = new PaymentRefundedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -168,36 +173,40 @@ public Card getCard() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __transactionJson = JsonUtil.getObject(json, "transaction"); - if (__transactionJson != null) { - obj.transaction = Transaction.fromJson(__transactionJson); + JsonObject __transactionObj = JsonUtil.getJsonObject(jsonObj, "transaction"); + if (__transactionObj != null) { + obj.transaction = Transaction.fromJson(__transactionObj); } - String __invoiceJson = JsonUtil.getObject(json, "invoice"); - if (__invoiceJson != null) { - obj.invoice = Invoice.fromJson(__invoiceJson); + JsonObject __invoiceObj = JsonUtil.getJsonObject(jsonObj, "invoice"); + if (__invoiceObj != null) { + obj.invoice = Invoice.fromJson(__invoiceObj); } - String __creditNoteJson = JsonUtil.getObject(json, "credit_note"); - if (__creditNoteJson != null) { - obj.creditNote = CreditNote.fromJson(__creditNoteJson); + JsonObject __creditNoteObj = JsonUtil.getJsonObject(jsonObj, "credit_note"); + if (__creditNoteObj != null) { + obj.creditNote = CreditNote.fromJson(__creditNoteObj); } - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - obj.customer = Customer.fromJson(__customerJson); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + obj.customer = Customer.fromJson(__customerObj); } - String __subscriptionJson = JsonUtil.getObject(json, "subscription"); - if (__subscriptionJson != null) { - obj.subscription = Subscription.fromJson(__subscriptionJson); + JsonObject __subscriptionObj = JsonUtil.getJsonObject(jsonObj, "subscription"); + if (__subscriptionObj != null) { + obj.subscription = Subscription.fromJson(__subscriptionObj); } - String __cardJson = JsonUtil.getObject(json, "card"); - if (__cardJson != null) { - obj.card = Card.fromJson(__cardJson); + JsonObject __cardObj = JsonUtil.getJsonObject(jsonObj, "card"); + if (__cardObj != null) { + obj.card = Card.fromJson(__cardObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/PaymentScheduleSchemeCreatedEvent.java b/src/main/java/com/chargebee/v4/models/event/PaymentScheduleSchemeCreatedEvent.java index 480f57ad..909b93f8 100644 --- a/src/main/java/com/chargebee/v4/models/event/PaymentScheduleSchemeCreatedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/PaymentScheduleSchemeCreatedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.paymentScheduleScheme.PaymentScheduleScheme; @@ -55,25 +56,29 @@ public Content getContent() { } public static PaymentScheduleSchemeCreatedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static PaymentScheduleSchemeCreatedEvent fromJson(JsonObject jsonObj) { PaymentScheduleSchemeCreatedEvent obj = new PaymentScheduleSchemeCreatedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -138,14 +143,19 @@ public Object getFlexibleSchedules() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __paymentScheduleSchemeJson = JsonUtil.getObject(json, "payment_schedule_scheme"); - if (__paymentScheduleSchemeJson != null) { - obj.paymentScheduleScheme = PaymentScheduleScheme.fromJson(__paymentScheduleSchemeJson); + JsonObject __paymentScheduleSchemeObj = + JsonUtil.getJsonObject(jsonObj, "payment_schedule_scheme"); + if (__paymentScheduleSchemeObj != null) { + obj.paymentScheduleScheme = PaymentScheduleScheme.fromJson(__paymentScheduleSchemeObj); } - obj.flexibleSchedules = JsonUtil.getObject(json, "flexible_schedules"); + obj.flexibleSchedules = JsonUtil.getObject(jsonObj, "flexible_schedules"); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/event/PaymentScheduleSchemeDeletedEvent.java b/src/main/java/com/chargebee/v4/models/event/PaymentScheduleSchemeDeletedEvent.java index 9075fb22..e3fa0f21 100644 --- a/src/main/java/com/chargebee/v4/models/event/PaymentScheduleSchemeDeletedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/PaymentScheduleSchemeDeletedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.paymentScheduleScheme.PaymentScheduleScheme; @@ -55,25 +56,29 @@ public Content getContent() { } public static PaymentScheduleSchemeDeletedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static PaymentScheduleSchemeDeletedEvent fromJson(JsonObject jsonObj) { PaymentScheduleSchemeDeletedEvent obj = new PaymentScheduleSchemeDeletedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -138,14 +143,19 @@ public Object getFlexibleSchedules() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __paymentScheduleSchemeJson = JsonUtil.getObject(json, "payment_schedule_scheme"); - if (__paymentScheduleSchemeJson != null) { - obj.paymentScheduleScheme = PaymentScheduleScheme.fromJson(__paymentScheduleSchemeJson); + JsonObject __paymentScheduleSchemeObj = + JsonUtil.getJsonObject(jsonObj, "payment_schedule_scheme"); + if (__paymentScheduleSchemeObj != null) { + obj.paymentScheduleScheme = PaymentScheduleScheme.fromJson(__paymentScheduleSchemeObj); } - obj.flexibleSchedules = JsonUtil.getObject(json, "flexible_schedules"); + obj.flexibleSchedules = JsonUtil.getObject(jsonObj, "flexible_schedules"); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/event/PaymentSchedulesCreatedEvent.java b/src/main/java/com/chargebee/v4/models/event/PaymentSchedulesCreatedEvent.java index 2411fee8..5d81ad03 100644 --- a/src/main/java/com/chargebee/v4/models/event/PaymentSchedulesCreatedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/PaymentSchedulesCreatedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.paymentSchedule.PaymentSchedule; @@ -55,25 +56,29 @@ public Content getContent() { } public static PaymentSchedulesCreatedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static PaymentSchedulesCreatedEvent fromJson(JsonObject jsonObj) { PaymentSchedulesCreatedEvent obj = new PaymentSchedulesCreatedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -133,11 +138,15 @@ public PaymentSchedule getPaymentSchedule() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __paymentScheduleJson = JsonUtil.getObject(json, "payment_schedule"); - if (__paymentScheduleJson != null) { - obj.paymentSchedule = PaymentSchedule.fromJson(__paymentScheduleJson); + JsonObject __paymentScheduleObj = JsonUtil.getJsonObject(jsonObj, "payment_schedule"); + if (__paymentScheduleObj != null) { + obj.paymentSchedule = PaymentSchedule.fromJson(__paymentScheduleObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/PaymentSchedulesUpdatedEvent.java b/src/main/java/com/chargebee/v4/models/event/PaymentSchedulesUpdatedEvent.java index c5a4770a..398dfc2f 100644 --- a/src/main/java/com/chargebee/v4/models/event/PaymentSchedulesUpdatedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/PaymentSchedulesUpdatedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.paymentSchedule.PaymentSchedule; @@ -55,25 +56,29 @@ public Content getContent() { } public static PaymentSchedulesUpdatedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static PaymentSchedulesUpdatedEvent fromJson(JsonObject jsonObj) { PaymentSchedulesUpdatedEvent obj = new PaymentSchedulesUpdatedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -133,11 +138,15 @@ public PaymentSchedule getPaymentSchedule() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __paymentScheduleJson = JsonUtil.getObject(json, "payment_schedule"); - if (__paymentScheduleJson != null) { - obj.paymentSchedule = PaymentSchedule.fromJson(__paymentScheduleJson); + JsonObject __paymentScheduleObj = JsonUtil.getJsonObject(jsonObj, "payment_schedule"); + if (__paymentScheduleObj != null) { + obj.paymentSchedule = PaymentSchedule.fromJson(__paymentScheduleObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/PaymentSourceAddedEvent.java b/src/main/java/com/chargebee/v4/models/event/PaymentSourceAddedEvent.java index 2407cf06..52258559 100644 --- a/src/main/java/com/chargebee/v4/models/event/PaymentSourceAddedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/PaymentSourceAddedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.customer.Customer; @@ -57,25 +58,29 @@ public Content getContent() { } public static PaymentSourceAddedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static PaymentSourceAddedEvent fromJson(JsonObject jsonObj) { PaymentSourceAddedEvent obj = new PaymentSourceAddedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -140,16 +145,20 @@ public PaymentSource getPaymentSource() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - obj.customer = Customer.fromJson(__customerJson); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + obj.customer = Customer.fromJson(__customerObj); } - String __paymentSourceJson = JsonUtil.getObject(json, "payment_source"); - if (__paymentSourceJson != null) { - obj.paymentSource = PaymentSource.fromJson(__paymentSourceJson); + JsonObject __paymentSourceObj = JsonUtil.getJsonObject(jsonObj, "payment_source"); + if (__paymentSourceObj != null) { + obj.paymentSource = PaymentSource.fromJson(__paymentSourceObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/PaymentSourceDeletedEvent.java b/src/main/java/com/chargebee/v4/models/event/PaymentSourceDeletedEvent.java index 16be0666..2ccc242c 100644 --- a/src/main/java/com/chargebee/v4/models/event/PaymentSourceDeletedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/PaymentSourceDeletedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.customer.Customer; @@ -57,25 +58,29 @@ public Content getContent() { } public static PaymentSourceDeletedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static PaymentSourceDeletedEvent fromJson(JsonObject jsonObj) { PaymentSourceDeletedEvent obj = new PaymentSourceDeletedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -140,16 +145,20 @@ public PaymentSource getPaymentSource() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - obj.customer = Customer.fromJson(__customerJson); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + obj.customer = Customer.fromJson(__customerObj); } - String __paymentSourceJson = JsonUtil.getObject(json, "payment_source"); - if (__paymentSourceJson != null) { - obj.paymentSource = PaymentSource.fromJson(__paymentSourceJson); + JsonObject __paymentSourceObj = JsonUtil.getJsonObject(jsonObj, "payment_source"); + if (__paymentSourceObj != null) { + obj.paymentSource = PaymentSource.fromJson(__paymentSourceObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/PaymentSourceExpiredEvent.java b/src/main/java/com/chargebee/v4/models/event/PaymentSourceExpiredEvent.java index ce46c6eb..915efe13 100644 --- a/src/main/java/com/chargebee/v4/models/event/PaymentSourceExpiredEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/PaymentSourceExpiredEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.customer.Customer; @@ -57,25 +58,29 @@ public Content getContent() { } public static PaymentSourceExpiredEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static PaymentSourceExpiredEvent fromJson(JsonObject jsonObj) { PaymentSourceExpiredEvent obj = new PaymentSourceExpiredEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -140,16 +145,20 @@ public PaymentSource getPaymentSource() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - obj.customer = Customer.fromJson(__customerJson); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + obj.customer = Customer.fromJson(__customerObj); } - String __paymentSourceJson = JsonUtil.getObject(json, "payment_source"); - if (__paymentSourceJson != null) { - obj.paymentSource = PaymentSource.fromJson(__paymentSourceJson); + JsonObject __paymentSourceObj = JsonUtil.getJsonObject(jsonObj, "payment_source"); + if (__paymentSourceObj != null) { + obj.paymentSource = PaymentSource.fromJson(__paymentSourceObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/PaymentSourceExpiringEvent.java b/src/main/java/com/chargebee/v4/models/event/PaymentSourceExpiringEvent.java index bda386cf..b7c08c28 100644 --- a/src/main/java/com/chargebee/v4/models/event/PaymentSourceExpiringEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/PaymentSourceExpiringEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.customer.Customer; @@ -57,25 +58,29 @@ public Content getContent() { } public static PaymentSourceExpiringEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static PaymentSourceExpiringEvent fromJson(JsonObject jsonObj) { PaymentSourceExpiringEvent obj = new PaymentSourceExpiringEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -140,16 +145,20 @@ public PaymentSource getPaymentSource() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - obj.customer = Customer.fromJson(__customerJson); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + obj.customer = Customer.fromJson(__customerObj); } - String __paymentSourceJson = JsonUtil.getObject(json, "payment_source"); - if (__paymentSourceJson != null) { - obj.paymentSource = PaymentSource.fromJson(__paymentSourceJson); + JsonObject __paymentSourceObj = JsonUtil.getJsonObject(jsonObj, "payment_source"); + if (__paymentSourceObj != null) { + obj.paymentSource = PaymentSource.fromJson(__paymentSourceObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/PaymentSourceLocallyDeletedEvent.java b/src/main/java/com/chargebee/v4/models/event/PaymentSourceLocallyDeletedEvent.java index 7ca5048c..4feed422 100644 --- a/src/main/java/com/chargebee/v4/models/event/PaymentSourceLocallyDeletedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/PaymentSourceLocallyDeletedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.customer.Customer; @@ -57,25 +58,29 @@ public Content getContent() { } public static PaymentSourceLocallyDeletedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static PaymentSourceLocallyDeletedEvent fromJson(JsonObject jsonObj) { PaymentSourceLocallyDeletedEvent obj = new PaymentSourceLocallyDeletedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -140,16 +145,20 @@ public PaymentSource getPaymentSource() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - obj.customer = Customer.fromJson(__customerJson); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + obj.customer = Customer.fromJson(__customerObj); } - String __paymentSourceJson = JsonUtil.getObject(json, "payment_source"); - if (__paymentSourceJson != null) { - obj.paymentSource = PaymentSource.fromJson(__paymentSourceJson); + JsonObject __paymentSourceObj = JsonUtil.getJsonObject(jsonObj, "payment_source"); + if (__paymentSourceObj != null) { + obj.paymentSource = PaymentSource.fromJson(__paymentSourceObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/PaymentSourceUpdatedEvent.java b/src/main/java/com/chargebee/v4/models/event/PaymentSourceUpdatedEvent.java index a92f3b2f..f8671ff2 100644 --- a/src/main/java/com/chargebee/v4/models/event/PaymentSourceUpdatedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/PaymentSourceUpdatedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.customer.Customer; @@ -57,25 +58,29 @@ public Content getContent() { } public static PaymentSourceUpdatedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static PaymentSourceUpdatedEvent fromJson(JsonObject jsonObj) { PaymentSourceUpdatedEvent obj = new PaymentSourceUpdatedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -140,16 +145,20 @@ public PaymentSource getPaymentSource() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - obj.customer = Customer.fromJson(__customerJson); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + obj.customer = Customer.fromJson(__customerObj); } - String __paymentSourceJson = JsonUtil.getObject(json, "payment_source"); - if (__paymentSourceJson != null) { - obj.paymentSource = PaymentSource.fromJson(__paymentSourceJson); + JsonObject __paymentSourceObj = JsonUtil.getJsonObject(jsonObj, "payment_source"); + if (__paymentSourceObj != null) { + obj.paymentSource = PaymentSource.fromJson(__paymentSourceObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/PaymentSucceededEvent.java b/src/main/java/com/chargebee/v4/models/event/PaymentSucceededEvent.java index 4bf76407..4e1b97c7 100644 --- a/src/main/java/com/chargebee/v4/models/event/PaymentSucceededEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/PaymentSucceededEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.customer.Customer; @@ -63,25 +64,29 @@ public Content getContent() { } public static PaymentSucceededEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static PaymentSucceededEvent fromJson(JsonObject jsonObj) { PaymentSucceededEvent obj = new PaymentSucceededEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -161,31 +166,35 @@ public Card getCard() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __transactionJson = JsonUtil.getObject(json, "transaction"); - if (__transactionJson != null) { - obj.transaction = Transaction.fromJson(__transactionJson); + JsonObject __transactionObj = JsonUtil.getJsonObject(jsonObj, "transaction"); + if (__transactionObj != null) { + obj.transaction = Transaction.fromJson(__transactionObj); } - String __invoiceJson = JsonUtil.getObject(json, "invoice"); - if (__invoiceJson != null) { - obj.invoice = Invoice.fromJson(__invoiceJson); + JsonObject __invoiceObj = JsonUtil.getJsonObject(jsonObj, "invoice"); + if (__invoiceObj != null) { + obj.invoice = Invoice.fromJson(__invoiceObj); } - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - obj.customer = Customer.fromJson(__customerJson); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + obj.customer = Customer.fromJson(__customerObj); } - String __subscriptionJson = JsonUtil.getObject(json, "subscription"); - if (__subscriptionJson != null) { - obj.subscription = Subscription.fromJson(__subscriptionJson); + JsonObject __subscriptionObj = JsonUtil.getJsonObject(jsonObj, "subscription"); + if (__subscriptionObj != null) { + obj.subscription = Subscription.fromJson(__subscriptionObj); } - String __cardJson = JsonUtil.getObject(json, "card"); - if (__cardJson != null) { - obj.card = Card.fromJson(__cardJson); + JsonObject __cardObj = JsonUtil.getJsonObject(jsonObj, "card"); + if (__cardObj != null) { + obj.card = Card.fromJson(__cardObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/PendingInvoiceCreatedEvent.java b/src/main/java/com/chargebee/v4/models/event/PendingInvoiceCreatedEvent.java index f3bedbbd..42ddc9c1 100644 --- a/src/main/java/com/chargebee/v4/models/event/PendingInvoiceCreatedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/PendingInvoiceCreatedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.invoice.Invoice; @@ -55,25 +56,29 @@ public Content getContent() { } public static PendingInvoiceCreatedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static PendingInvoiceCreatedEvent fromJson(JsonObject jsonObj) { PendingInvoiceCreatedEvent obj = new PendingInvoiceCreatedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -133,11 +138,15 @@ public Invoice getInvoice() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __invoiceJson = JsonUtil.getObject(json, "invoice"); - if (__invoiceJson != null) { - obj.invoice = Invoice.fromJson(__invoiceJson); + JsonObject __invoiceObj = JsonUtil.getJsonObject(jsonObj, "invoice"); + if (__invoiceObj != null) { + obj.invoice = Invoice.fromJson(__invoiceObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/PendingInvoiceUpdatedEvent.java b/src/main/java/com/chargebee/v4/models/event/PendingInvoiceUpdatedEvent.java index bb9748e0..4c745301 100644 --- a/src/main/java/com/chargebee/v4/models/event/PendingInvoiceUpdatedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/PendingInvoiceUpdatedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.invoice.Invoice; @@ -55,25 +56,29 @@ public Content getContent() { } public static PendingInvoiceUpdatedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static PendingInvoiceUpdatedEvent fromJson(JsonObject jsonObj) { PendingInvoiceUpdatedEvent obj = new PendingInvoiceUpdatedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -133,11 +138,15 @@ public Invoice getInvoice() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __invoiceJson = JsonUtil.getObject(json, "invoice"); - if (__invoiceJson != null) { - obj.invoice = Invoice.fromJson(__invoiceJson); + JsonObject __invoiceObj = JsonUtil.getJsonObject(jsonObj, "invoice"); + if (__invoiceObj != null) { + obj.invoice = Invoice.fromJson(__invoiceObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/PlanCreatedEvent.java b/src/main/java/com/chargebee/v4/models/event/PlanCreatedEvent.java index 2cb555a2..6110ed78 100644 --- a/src/main/java/com/chargebee/v4/models/event/PlanCreatedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/PlanCreatedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.plan.Plan; @@ -55,25 +56,29 @@ public Content getContent() { } public static PlanCreatedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static PlanCreatedEvent fromJson(JsonObject jsonObj) { PlanCreatedEvent obj = new PlanCreatedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -133,11 +138,15 @@ public Plan getPlan() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __planJson = JsonUtil.getObject(json, "plan"); - if (__planJson != null) { - obj.plan = Plan.fromJson(__planJson); + JsonObject __planObj = JsonUtil.getJsonObject(jsonObj, "plan"); + if (__planObj != null) { + obj.plan = Plan.fromJson(__planObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/PlanDeletedEvent.java b/src/main/java/com/chargebee/v4/models/event/PlanDeletedEvent.java index 5ef759e4..dba0f694 100644 --- a/src/main/java/com/chargebee/v4/models/event/PlanDeletedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/PlanDeletedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.plan.Plan; @@ -55,25 +56,29 @@ public Content getContent() { } public static PlanDeletedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static PlanDeletedEvent fromJson(JsonObject jsonObj) { PlanDeletedEvent obj = new PlanDeletedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -133,11 +138,15 @@ public Plan getPlan() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __planJson = JsonUtil.getObject(json, "plan"); - if (__planJson != null) { - obj.plan = Plan.fromJson(__planJson); + JsonObject __planObj = JsonUtil.getJsonObject(jsonObj, "plan"); + if (__planObj != null) { + obj.plan = Plan.fromJson(__planObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/PlanUpdatedEvent.java b/src/main/java/com/chargebee/v4/models/event/PlanUpdatedEvent.java index b78c796b..9e8b4e29 100644 --- a/src/main/java/com/chargebee/v4/models/event/PlanUpdatedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/PlanUpdatedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.plan.Plan; @@ -55,25 +56,29 @@ public Content getContent() { } public static PlanUpdatedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static PlanUpdatedEvent fromJson(JsonObject jsonObj) { PlanUpdatedEvent obj = new PlanUpdatedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -133,11 +138,15 @@ public Plan getPlan() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __planJson = JsonUtil.getObject(json, "plan"); - if (__planJson != null) { - obj.plan = Plan.fromJson(__planJson); + JsonObject __planObj = JsonUtil.getJsonObject(jsonObj, "plan"); + if (__planObj != null) { + obj.plan = Plan.fromJson(__planObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/PriceVariantCreatedEvent.java b/src/main/java/com/chargebee/v4/models/event/PriceVariantCreatedEvent.java index 5e3bdd7c..768187f7 100644 --- a/src/main/java/com/chargebee/v4/models/event/PriceVariantCreatedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/PriceVariantCreatedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.priceVariant.PriceVariant; @@ -57,25 +58,29 @@ public Content getContent() { } public static PriceVariantCreatedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static PriceVariantCreatedEvent fromJson(JsonObject jsonObj) { PriceVariantCreatedEvent obj = new PriceVariantCreatedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -140,16 +145,20 @@ public Attribute getAttribute() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __priceVariantJson = JsonUtil.getObject(json, "price_variant"); - if (__priceVariantJson != null) { - obj.priceVariant = PriceVariant.fromJson(__priceVariantJson); + JsonObject __priceVariantObj = JsonUtil.getJsonObject(jsonObj, "price_variant"); + if (__priceVariantObj != null) { + obj.priceVariant = PriceVariant.fromJson(__priceVariantObj); } - String __attributeJson = JsonUtil.getObject(json, "attribute"); - if (__attributeJson != null) { - obj.attribute = Attribute.fromJson(__attributeJson); + JsonObject __attributeObj = JsonUtil.getJsonObject(jsonObj, "attribute"); + if (__attributeObj != null) { + obj.attribute = Attribute.fromJson(__attributeObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/PriceVariantDeletedEvent.java b/src/main/java/com/chargebee/v4/models/event/PriceVariantDeletedEvent.java index fa212e3f..9938e87e 100644 --- a/src/main/java/com/chargebee/v4/models/event/PriceVariantDeletedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/PriceVariantDeletedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.priceVariant.PriceVariant; @@ -57,25 +58,29 @@ public Content getContent() { } public static PriceVariantDeletedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static PriceVariantDeletedEvent fromJson(JsonObject jsonObj) { PriceVariantDeletedEvent obj = new PriceVariantDeletedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -140,16 +145,20 @@ public Attribute getAttribute() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __priceVariantJson = JsonUtil.getObject(json, "price_variant"); - if (__priceVariantJson != null) { - obj.priceVariant = PriceVariant.fromJson(__priceVariantJson); + JsonObject __priceVariantObj = JsonUtil.getJsonObject(jsonObj, "price_variant"); + if (__priceVariantObj != null) { + obj.priceVariant = PriceVariant.fromJson(__priceVariantObj); } - String __attributeJson = JsonUtil.getObject(json, "attribute"); - if (__attributeJson != null) { - obj.attribute = Attribute.fromJson(__attributeJson); + JsonObject __attributeObj = JsonUtil.getJsonObject(jsonObj, "attribute"); + if (__attributeObj != null) { + obj.attribute = Attribute.fromJson(__attributeObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/PriceVariantUpdatedEvent.java b/src/main/java/com/chargebee/v4/models/event/PriceVariantUpdatedEvent.java index e416cc1f..61db7805 100644 --- a/src/main/java/com/chargebee/v4/models/event/PriceVariantUpdatedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/PriceVariantUpdatedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.priceVariant.PriceVariant; @@ -57,25 +58,29 @@ public Content getContent() { } public static PriceVariantUpdatedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static PriceVariantUpdatedEvent fromJson(JsonObject jsonObj) { PriceVariantUpdatedEvent obj = new PriceVariantUpdatedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -140,16 +145,20 @@ public Attribute getAttribute() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __priceVariantJson = JsonUtil.getObject(json, "price_variant"); - if (__priceVariantJson != null) { - obj.priceVariant = PriceVariant.fromJson(__priceVariantJson); + JsonObject __priceVariantObj = JsonUtil.getJsonObject(jsonObj, "price_variant"); + if (__priceVariantObj != null) { + obj.priceVariant = PriceVariant.fromJson(__priceVariantObj); } - String __attributeJson = JsonUtil.getObject(json, "attribute"); - if (__attributeJson != null) { - obj.attribute = Attribute.fromJson(__attributeJson); + JsonObject __attributeObj = JsonUtil.getJsonObject(jsonObj, "attribute"); + if (__attributeObj != null) { + obj.attribute = Attribute.fromJson(__attributeObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/ProductCreatedEvent.java b/src/main/java/com/chargebee/v4/models/event/ProductCreatedEvent.java index 9369b016..a03de471 100644 --- a/src/main/java/com/chargebee/v4/models/event/ProductCreatedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/ProductCreatedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.product.Product; @@ -55,25 +56,29 @@ public Content getContent() { } public static ProductCreatedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static ProductCreatedEvent fromJson(JsonObject jsonObj) { ProductCreatedEvent obj = new ProductCreatedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -133,11 +138,15 @@ public Product getProduct() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __productJson = JsonUtil.getObject(json, "product"); - if (__productJson != null) { - obj.product = Product.fromJson(__productJson); + JsonObject __productObj = JsonUtil.getJsonObject(jsonObj, "product"); + if (__productObj != null) { + obj.product = Product.fromJson(__productObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/ProductDeletedEvent.java b/src/main/java/com/chargebee/v4/models/event/ProductDeletedEvent.java index c0d7f4a5..173a109e 100644 --- a/src/main/java/com/chargebee/v4/models/event/ProductDeletedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/ProductDeletedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.product.Product; @@ -55,25 +56,29 @@ public Content getContent() { } public static ProductDeletedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static ProductDeletedEvent fromJson(JsonObject jsonObj) { ProductDeletedEvent obj = new ProductDeletedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -133,11 +138,15 @@ public Product getProduct() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __productJson = JsonUtil.getObject(json, "product"); - if (__productJson != null) { - obj.product = Product.fromJson(__productJson); + JsonObject __productObj = JsonUtil.getJsonObject(jsonObj, "product"); + if (__productObj != null) { + obj.product = Product.fromJson(__productObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/ProductUpdatedEvent.java b/src/main/java/com/chargebee/v4/models/event/ProductUpdatedEvent.java index 656f80d2..318183e2 100644 --- a/src/main/java/com/chargebee/v4/models/event/ProductUpdatedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/ProductUpdatedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.product.Product; @@ -55,25 +56,29 @@ public Content getContent() { } public static ProductUpdatedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static ProductUpdatedEvent fromJson(JsonObject jsonObj) { ProductUpdatedEvent obj = new ProductUpdatedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -133,11 +138,15 @@ public Product getProduct() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __productJson = JsonUtil.getObject(json, "product"); - if (__productJson != null) { - obj.product = Product.fromJson(__productJson); + JsonObject __productObj = JsonUtil.getJsonObject(jsonObj, "product"); + if (__productObj != null) { + obj.product = Product.fromJson(__productObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/PromotionalCreditsAddedEvent.java b/src/main/java/com/chargebee/v4/models/event/PromotionalCreditsAddedEvent.java index b0ec85ac..4826d1c1 100644 --- a/src/main/java/com/chargebee/v4/models/event/PromotionalCreditsAddedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/PromotionalCreditsAddedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.customer.Customer; @@ -57,25 +58,29 @@ public Content getContent() { } public static PromotionalCreditsAddedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static PromotionalCreditsAddedEvent fromJson(JsonObject jsonObj) { PromotionalCreditsAddedEvent obj = new PromotionalCreditsAddedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -140,16 +145,20 @@ public PromotionalCredit getPromotionalCredit() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - obj.customer = Customer.fromJson(__customerJson); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + obj.customer = Customer.fromJson(__customerObj); } - String __promotionalCreditJson = JsonUtil.getObject(json, "promotional_credit"); - if (__promotionalCreditJson != null) { - obj.promotionalCredit = PromotionalCredit.fromJson(__promotionalCreditJson); + JsonObject __promotionalCreditObj = JsonUtil.getJsonObject(jsonObj, "promotional_credit"); + if (__promotionalCreditObj != null) { + obj.promotionalCredit = PromotionalCredit.fromJson(__promotionalCreditObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/PromotionalCreditsDeductedEvent.java b/src/main/java/com/chargebee/v4/models/event/PromotionalCreditsDeductedEvent.java index 681ddccc..4e8fefc2 100644 --- a/src/main/java/com/chargebee/v4/models/event/PromotionalCreditsDeductedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/PromotionalCreditsDeductedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.customer.Customer; @@ -57,25 +58,29 @@ public Content getContent() { } public static PromotionalCreditsDeductedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static PromotionalCreditsDeductedEvent fromJson(JsonObject jsonObj) { PromotionalCreditsDeductedEvent obj = new PromotionalCreditsDeductedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -140,16 +145,20 @@ public PromotionalCredit getPromotionalCredit() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - obj.customer = Customer.fromJson(__customerJson); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + obj.customer = Customer.fromJson(__customerObj); } - String __promotionalCreditJson = JsonUtil.getObject(json, "promotional_credit"); - if (__promotionalCreditJson != null) { - obj.promotionalCredit = PromotionalCredit.fromJson(__promotionalCreditJson); + JsonObject __promotionalCreditObj = JsonUtil.getJsonObject(jsonObj, "promotional_credit"); + if (__promotionalCreditObj != null) { + obj.promotionalCredit = PromotionalCredit.fromJson(__promotionalCreditObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/PurchaseCreatedEvent.java b/src/main/java/com/chargebee/v4/models/event/PurchaseCreatedEvent.java index 58e431c1..e9a02981 100644 --- a/src/main/java/com/chargebee/v4/models/event/PurchaseCreatedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/PurchaseCreatedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.purchase.Purchase; @@ -55,25 +56,29 @@ public Content getContent() { } public static PurchaseCreatedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static PurchaseCreatedEvent fromJson(JsonObject jsonObj) { PurchaseCreatedEvent obj = new PurchaseCreatedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -133,11 +138,15 @@ public Purchase getPurchase() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __purchaseJson = JsonUtil.getObject(json, "purchase"); - if (__purchaseJson != null) { - obj.purchase = Purchase.fromJson(__purchaseJson); + JsonObject __purchaseObj = JsonUtil.getJsonObject(jsonObj, "purchase"); + if (__purchaseObj != null) { + obj.purchase = Purchase.fromJson(__purchaseObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/QuoteCreatedEvent.java b/src/main/java/com/chargebee/v4/models/event/QuoteCreatedEvent.java index 85ffdea6..9449e9b7 100644 --- a/src/main/java/com/chargebee/v4/models/event/QuoteCreatedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/QuoteCreatedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.quote.Quote; @@ -55,25 +56,29 @@ public Content getContent() { } public static QuoteCreatedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static QuoteCreatedEvent fromJson(JsonObject jsonObj) { QuoteCreatedEvent obj = new QuoteCreatedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -133,11 +138,15 @@ public Quote getQuote() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __quoteJson = JsonUtil.getObject(json, "quote"); - if (__quoteJson != null) { - obj.quote = Quote.fromJson(__quoteJson); + JsonObject __quoteObj = JsonUtil.getJsonObject(jsonObj, "quote"); + if (__quoteObj != null) { + obj.quote = Quote.fromJson(__quoteObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/QuoteDeletedEvent.java b/src/main/java/com/chargebee/v4/models/event/QuoteDeletedEvent.java index cf845191..3c8fd656 100644 --- a/src/main/java/com/chargebee/v4/models/event/QuoteDeletedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/QuoteDeletedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.quote.Quote; @@ -55,25 +56,29 @@ public Content getContent() { } public static QuoteDeletedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static QuoteDeletedEvent fromJson(JsonObject jsonObj) { QuoteDeletedEvent obj = new QuoteDeletedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -133,11 +138,15 @@ public Quote getQuote() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __quoteJson = JsonUtil.getObject(json, "quote"); - if (__quoteJson != null) { - obj.quote = Quote.fromJson(__quoteJson); + JsonObject __quoteObj = JsonUtil.getJsonObject(jsonObj, "quote"); + if (__quoteObj != null) { + obj.quote = Quote.fromJson(__quoteObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/QuoteUpdatedEvent.java b/src/main/java/com/chargebee/v4/models/event/QuoteUpdatedEvent.java index 3b088489..1619461f 100644 --- a/src/main/java/com/chargebee/v4/models/event/QuoteUpdatedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/QuoteUpdatedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.quote.Quote; @@ -55,25 +56,29 @@ public Content getContent() { } public static QuoteUpdatedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static QuoteUpdatedEvent fromJson(JsonObject jsonObj) { QuoteUpdatedEvent obj = new QuoteUpdatedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -133,11 +138,15 @@ public Quote getQuote() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __quoteJson = JsonUtil.getObject(json, "quote"); - if (__quoteJson != null) { - obj.quote = Quote.fromJson(__quoteJson); + JsonObject __quoteObj = JsonUtil.getJsonObject(jsonObj, "quote"); + if (__quoteObj != null) { + obj.quote = Quote.fromJson(__quoteObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/RecordPurchaseFailedEvent.java b/src/main/java/com/chargebee/v4/models/event/RecordPurchaseFailedEvent.java index 0c128628..acc1921d 100644 --- a/src/main/java/com/chargebee/v4/models/event/RecordPurchaseFailedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/RecordPurchaseFailedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.customer.Customer; @@ -57,25 +58,29 @@ public Content getContent() { } public static RecordPurchaseFailedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static RecordPurchaseFailedEvent fromJson(JsonObject jsonObj) { RecordPurchaseFailedEvent obj = new RecordPurchaseFailedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -140,16 +145,20 @@ public Customer getCustomer() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __recordedPurchaseJson = JsonUtil.getObject(json, "recorded_purchase"); - if (__recordedPurchaseJson != null) { - obj.recordedPurchase = RecordedPurchase.fromJson(__recordedPurchaseJson); + JsonObject __recordedPurchaseObj = JsonUtil.getJsonObject(jsonObj, "recorded_purchase"); + if (__recordedPurchaseObj != null) { + obj.recordedPurchase = RecordedPurchase.fromJson(__recordedPurchaseObj); } - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - obj.customer = Customer.fromJson(__customerJson); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + obj.customer = Customer.fromJson(__customerObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/RefundInitiatedEvent.java b/src/main/java/com/chargebee/v4/models/event/RefundInitiatedEvent.java index 6ac987d1..a1730fb4 100644 --- a/src/main/java/com/chargebee/v4/models/event/RefundInitiatedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/RefundInitiatedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.customer.Customer; @@ -65,25 +66,29 @@ public Content getContent() { } public static RefundInitiatedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static RefundInitiatedEvent fromJson(JsonObject jsonObj) { RefundInitiatedEvent obj = new RefundInitiatedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -168,36 +173,40 @@ public Card getCard() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __transactionJson = JsonUtil.getObject(json, "transaction"); - if (__transactionJson != null) { - obj.transaction = Transaction.fromJson(__transactionJson); + JsonObject __transactionObj = JsonUtil.getJsonObject(jsonObj, "transaction"); + if (__transactionObj != null) { + obj.transaction = Transaction.fromJson(__transactionObj); } - String __invoiceJson = JsonUtil.getObject(json, "invoice"); - if (__invoiceJson != null) { - obj.invoice = Invoice.fromJson(__invoiceJson); + JsonObject __invoiceObj = JsonUtil.getJsonObject(jsonObj, "invoice"); + if (__invoiceObj != null) { + obj.invoice = Invoice.fromJson(__invoiceObj); } - String __creditNoteJson = JsonUtil.getObject(json, "credit_note"); - if (__creditNoteJson != null) { - obj.creditNote = CreditNote.fromJson(__creditNoteJson); + JsonObject __creditNoteObj = JsonUtil.getJsonObject(jsonObj, "credit_note"); + if (__creditNoteObj != null) { + obj.creditNote = CreditNote.fromJson(__creditNoteObj); } - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - obj.customer = Customer.fromJson(__customerJson); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + obj.customer = Customer.fromJson(__customerObj); } - String __subscriptionJson = JsonUtil.getObject(json, "subscription"); - if (__subscriptionJson != null) { - obj.subscription = Subscription.fromJson(__subscriptionJson); + JsonObject __subscriptionObj = JsonUtil.getJsonObject(jsonObj, "subscription"); + if (__subscriptionObj != null) { + obj.subscription = Subscription.fromJson(__subscriptionObj); } - String __cardJson = JsonUtil.getObject(json, "card"); - if (__cardJson != null) { - obj.card = Card.fromJson(__cardJson); + JsonObject __cardObj = JsonUtil.getJsonObject(jsonObj, "card"); + if (__cardObj != null) { + obj.card = Card.fromJson(__cardObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/RuleCreatedEvent.java b/src/main/java/com/chargebee/v4/models/event/RuleCreatedEvent.java index 246a90fd..6c7acebf 100644 --- a/src/main/java/com/chargebee/v4/models/event/RuleCreatedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/RuleCreatedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.rule.Rule; @@ -55,25 +56,29 @@ public Content getContent() { } public static RuleCreatedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static RuleCreatedEvent fromJson(JsonObject jsonObj) { RuleCreatedEvent obj = new RuleCreatedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -133,11 +138,15 @@ public Rule getRule() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __ruleJson = JsonUtil.getObject(json, "rule"); - if (__ruleJson != null) { - obj.rule = Rule.fromJson(__ruleJson); + JsonObject __ruleObj = JsonUtil.getJsonObject(jsonObj, "rule"); + if (__ruleObj != null) { + obj.rule = Rule.fromJson(__ruleObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/RuleDeletedEvent.java b/src/main/java/com/chargebee/v4/models/event/RuleDeletedEvent.java index 37a66047..869f4570 100644 --- a/src/main/java/com/chargebee/v4/models/event/RuleDeletedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/RuleDeletedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.rule.Rule; @@ -55,25 +56,29 @@ public Content getContent() { } public static RuleDeletedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static RuleDeletedEvent fromJson(JsonObject jsonObj) { RuleDeletedEvent obj = new RuleDeletedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -133,11 +138,15 @@ public Rule getRule() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __ruleJson = JsonUtil.getObject(json, "rule"); - if (__ruleJson != null) { - obj.rule = Rule.fromJson(__ruleJson); + JsonObject __ruleObj = JsonUtil.getJsonObject(jsonObj, "rule"); + if (__ruleObj != null) { + obj.rule = Rule.fromJson(__ruleObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/RuleUpdatedEvent.java b/src/main/java/com/chargebee/v4/models/event/RuleUpdatedEvent.java index 3c0be888..c78c29b5 100644 --- a/src/main/java/com/chargebee/v4/models/event/RuleUpdatedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/RuleUpdatedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.rule.Rule; @@ -55,25 +56,29 @@ public Content getContent() { } public static RuleUpdatedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static RuleUpdatedEvent fromJson(JsonObject jsonObj) { RuleUpdatedEvent obj = new RuleUpdatedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -133,11 +138,15 @@ public Rule getRule() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __ruleJson = JsonUtil.getObject(json, "rule"); - if (__ruleJson != null) { - obj.rule = Rule.fromJson(__ruleJson); + JsonObject __ruleObj = JsonUtil.getJsonObject(jsonObj, "rule"); + if (__ruleObj != null) { + obj.rule = Rule.fromJson(__ruleObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/SalesOrderCreatedEvent.java b/src/main/java/com/chargebee/v4/models/event/SalesOrderCreatedEvent.java index 71958e2b..2330effd 100644 --- a/src/main/java/com/chargebee/v4/models/event/SalesOrderCreatedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/SalesOrderCreatedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.salesOrder.SalesOrder; @@ -55,25 +56,29 @@ public Content getContent() { } public static SalesOrderCreatedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static SalesOrderCreatedEvent fromJson(JsonObject jsonObj) { SalesOrderCreatedEvent obj = new SalesOrderCreatedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -133,11 +138,15 @@ public SalesOrder getSalesOrder() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __salesOrderJson = JsonUtil.getObject(json, "sales_order"); - if (__salesOrderJson != null) { - obj.salesOrder = SalesOrder.fromJson(__salesOrderJson); + JsonObject __salesOrderObj = JsonUtil.getJsonObject(jsonObj, "sales_order"); + if (__salesOrderObj != null) { + obj.salesOrder = SalesOrder.fromJson(__salesOrderObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/SalesOrderUpdatedEvent.java b/src/main/java/com/chargebee/v4/models/event/SalesOrderUpdatedEvent.java index b30ab515..23a1446a 100644 --- a/src/main/java/com/chargebee/v4/models/event/SalesOrderUpdatedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/SalesOrderUpdatedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.salesOrder.SalesOrder; @@ -55,25 +56,29 @@ public Content getContent() { } public static SalesOrderUpdatedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static SalesOrderUpdatedEvent fromJson(JsonObject jsonObj) { SalesOrderUpdatedEvent obj = new SalesOrderUpdatedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -133,11 +138,15 @@ public SalesOrder getSalesOrder() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __salesOrderJson = JsonUtil.getObject(json, "sales_order"); - if (__salesOrderJson != null) { - obj.salesOrder = SalesOrder.fromJson(__salesOrderJson); + JsonObject __salesOrderObj = JsonUtil.getJsonObject(jsonObj, "sales_order"); + if (__salesOrderObj != null) { + obj.salesOrder = SalesOrder.fromJson(__salesOrderObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/SubscriptionActivatedEvent.java b/src/main/java/com/chargebee/v4/models/event/SubscriptionActivatedEvent.java index e47bbd22..306fdb43 100644 --- a/src/main/java/com/chargebee/v4/models/event/SubscriptionActivatedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/SubscriptionActivatedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.customer.Customer; @@ -61,25 +62,29 @@ public Content getContent() { } public static SubscriptionActivatedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static SubscriptionActivatedEvent fromJson(JsonObject jsonObj) { SubscriptionActivatedEvent obj = new SubscriptionActivatedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -154,26 +159,30 @@ public Invoice getInvoice() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __subscriptionJson = JsonUtil.getObject(json, "subscription"); - if (__subscriptionJson != null) { - obj.subscription = Subscription.fromJson(__subscriptionJson); + JsonObject __subscriptionObj = JsonUtil.getJsonObject(jsonObj, "subscription"); + if (__subscriptionObj != null) { + obj.subscription = Subscription.fromJson(__subscriptionObj); } - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - obj.customer = Customer.fromJson(__customerJson); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + obj.customer = Customer.fromJson(__customerObj); } - String __cardJson = JsonUtil.getObject(json, "card"); - if (__cardJson != null) { - obj.card = Card.fromJson(__cardJson); + JsonObject __cardObj = JsonUtil.getJsonObject(jsonObj, "card"); + if (__cardObj != null) { + obj.card = Card.fromJson(__cardObj); } - String __invoiceJson = JsonUtil.getObject(json, "invoice"); - if (__invoiceJson != null) { - obj.invoice = Invoice.fromJson(__invoiceJson); + JsonObject __invoiceObj = JsonUtil.getJsonObject(jsonObj, "invoice"); + if (__invoiceObj != null) { + obj.invoice = Invoice.fromJson(__invoiceObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/SubscriptionActivatedWithBackdatingEvent.java b/src/main/java/com/chargebee/v4/models/event/SubscriptionActivatedWithBackdatingEvent.java index 5cd055d2..3dcae559 100644 --- a/src/main/java/com/chargebee/v4/models/event/SubscriptionActivatedWithBackdatingEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/SubscriptionActivatedWithBackdatingEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import java.util.List; import com.chargebee.v4.models.customer.Customer; @@ -64,25 +65,29 @@ public Content getContent() { } public static SubscriptionActivatedWithBackdatingEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static SubscriptionActivatedWithBackdatingEvent fromJson(JsonObject jsonObj) { SubscriptionActivatedWithBackdatingEvent obj = new SubscriptionActivatedWithBackdatingEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -162,32 +167,35 @@ public List getUnbilledCharges() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __subscriptionJson = JsonUtil.getObject(json, "subscription"); - if (__subscriptionJson != null) { - obj.subscription = Subscription.fromJson(__subscriptionJson); + JsonObject __subscriptionObj = JsonUtil.getJsonObject(jsonObj, "subscription"); + if (__subscriptionObj != null) { + obj.subscription = Subscription.fromJson(__subscriptionObj); } - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - obj.customer = Customer.fromJson(__customerJson); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + obj.customer = Customer.fromJson(__customerObj); } - String __cardJson = JsonUtil.getObject(json, "card"); - if (__cardJson != null) { - obj.card = Card.fromJson(__cardJson); + JsonObject __cardObj = JsonUtil.getJsonObject(jsonObj, "card"); + if (__cardObj != null) { + obj.card = Card.fromJson(__cardObj); } - String __invoiceJson = JsonUtil.getObject(json, "invoice"); - if (__invoiceJson != null) { - obj.invoice = Invoice.fromJson(__invoiceJson); + JsonObject __invoiceObj = JsonUtil.getJsonObject(jsonObj, "invoice"); + if (__invoiceObj != null) { + obj.invoice = Invoice.fromJson(__invoiceObj); } obj.unbilledCharges = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "unbilled_charges")).stream() - .map(UnbilledCharge::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "unbilled_charges"), UnbilledCharge::fromJson); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/event/SubscriptionAdvanceInvoiceScheduleAddedEvent.java b/src/main/java/com/chargebee/v4/models/event/SubscriptionAdvanceInvoiceScheduleAddedEvent.java index 9ce9a3f2..c7a9cf20 100644 --- a/src/main/java/com/chargebee/v4/models/event/SubscriptionAdvanceInvoiceScheduleAddedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/SubscriptionAdvanceInvoiceScheduleAddedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import java.util.List; import com.chargebee.v4.models.customer.Customer; @@ -60,26 +61,30 @@ public Content getContent() { } public static SubscriptionAdvanceInvoiceScheduleAddedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static SubscriptionAdvanceInvoiceScheduleAddedEvent fromJson(JsonObject jsonObj) { SubscriptionAdvanceInvoiceScheduleAddedEvent obj = new SubscriptionAdvanceInvoiceScheduleAddedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -150,22 +155,26 @@ public List getAdvanceInvoiceSchedules() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __subscriptionJson = JsonUtil.getObject(json, "subscription"); - if (__subscriptionJson != null) { - obj.subscription = Subscription.fromJson(__subscriptionJson); + JsonObject __subscriptionObj = JsonUtil.getJsonObject(jsonObj, "subscription"); + if (__subscriptionObj != null) { + obj.subscription = Subscription.fromJson(__subscriptionObj); } - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - obj.customer = Customer.fromJson(__customerJson); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + obj.customer = Customer.fromJson(__customerObj); } obj.advanceInvoiceSchedules = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "advance_invoice_schedules")).stream() - .map(AdvanceInvoiceSchedule::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "advance_invoice_schedules"), + AdvanceInvoiceSchedule::fromJson); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/event/SubscriptionAdvanceInvoiceScheduleRemovedEvent.java b/src/main/java/com/chargebee/v4/models/event/SubscriptionAdvanceInvoiceScheduleRemovedEvent.java index 506d9fd0..b221ec55 100644 --- a/src/main/java/com/chargebee/v4/models/event/SubscriptionAdvanceInvoiceScheduleRemovedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/SubscriptionAdvanceInvoiceScheduleRemovedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import java.util.List; import com.chargebee.v4.models.customer.Customer; @@ -60,26 +61,30 @@ public Content getContent() { } public static SubscriptionAdvanceInvoiceScheduleRemovedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static SubscriptionAdvanceInvoiceScheduleRemovedEvent fromJson(JsonObject jsonObj) { SubscriptionAdvanceInvoiceScheduleRemovedEvent obj = new SubscriptionAdvanceInvoiceScheduleRemovedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -150,22 +155,26 @@ public List getAdvanceInvoiceSchedules() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __subscriptionJson = JsonUtil.getObject(json, "subscription"); - if (__subscriptionJson != null) { - obj.subscription = Subscription.fromJson(__subscriptionJson); + JsonObject __subscriptionObj = JsonUtil.getJsonObject(jsonObj, "subscription"); + if (__subscriptionObj != null) { + obj.subscription = Subscription.fromJson(__subscriptionObj); } - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - obj.customer = Customer.fromJson(__customerJson); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + obj.customer = Customer.fromJson(__customerObj); } obj.advanceInvoiceSchedules = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "advance_invoice_schedules")).stream() - .map(AdvanceInvoiceSchedule::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "advance_invoice_schedules"), + AdvanceInvoiceSchedule::fromJson); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/event/SubscriptionAdvanceInvoiceScheduleUpdatedEvent.java b/src/main/java/com/chargebee/v4/models/event/SubscriptionAdvanceInvoiceScheduleUpdatedEvent.java index 302d6eba..7718d57d 100644 --- a/src/main/java/com/chargebee/v4/models/event/SubscriptionAdvanceInvoiceScheduleUpdatedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/SubscriptionAdvanceInvoiceScheduleUpdatedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import java.util.List; import com.chargebee.v4.models.customer.Customer; @@ -60,26 +61,30 @@ public Content getContent() { } public static SubscriptionAdvanceInvoiceScheduleUpdatedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static SubscriptionAdvanceInvoiceScheduleUpdatedEvent fromJson(JsonObject jsonObj) { SubscriptionAdvanceInvoiceScheduleUpdatedEvent obj = new SubscriptionAdvanceInvoiceScheduleUpdatedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -150,22 +155,26 @@ public List getAdvanceInvoiceSchedules() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __subscriptionJson = JsonUtil.getObject(json, "subscription"); - if (__subscriptionJson != null) { - obj.subscription = Subscription.fromJson(__subscriptionJson); + JsonObject __subscriptionObj = JsonUtil.getJsonObject(jsonObj, "subscription"); + if (__subscriptionObj != null) { + obj.subscription = Subscription.fromJson(__subscriptionObj); } - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - obj.customer = Customer.fromJson(__customerJson); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + obj.customer = Customer.fromJson(__customerObj); } obj.advanceInvoiceSchedules = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "advance_invoice_schedules")).stream() - .map(AdvanceInvoiceSchedule::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "advance_invoice_schedules"), + AdvanceInvoiceSchedule::fromJson); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/event/SubscriptionBusinessEntityChangedEvent.java b/src/main/java/com/chargebee/v4/models/event/SubscriptionBusinessEntityChangedEvent.java index a834bb69..d9aed32d 100644 --- a/src/main/java/com/chargebee/v4/models/event/SubscriptionBusinessEntityChangedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/SubscriptionBusinessEntityChangedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.businessEntityTransfer.BusinessEntityTransfer; @@ -57,25 +58,29 @@ public Content getContent() { } public static SubscriptionBusinessEntityChangedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static SubscriptionBusinessEntityChangedEvent fromJson(JsonObject jsonObj) { SubscriptionBusinessEntityChangedEvent obj = new SubscriptionBusinessEntityChangedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -140,16 +145,21 @@ public Subscription getSubscription() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __businessEntityTransferJson = JsonUtil.getObject(json, "business_entity_transfer"); - if (__businessEntityTransferJson != null) { - obj.businessEntityTransfer = BusinessEntityTransfer.fromJson(__businessEntityTransferJson); + JsonObject __businessEntityTransferObj = + JsonUtil.getJsonObject(jsonObj, "business_entity_transfer"); + if (__businessEntityTransferObj != null) { + obj.businessEntityTransfer = BusinessEntityTransfer.fromJson(__businessEntityTransferObj); } - String __subscriptionJson = JsonUtil.getObject(json, "subscription"); - if (__subscriptionJson != null) { - obj.subscription = Subscription.fromJson(__subscriptionJson); + JsonObject __subscriptionObj = JsonUtil.getJsonObject(jsonObj, "subscription"); + if (__subscriptionObj != null) { + obj.subscription = Subscription.fromJson(__subscriptionObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/SubscriptionCanceledWithBackdatingEvent.java b/src/main/java/com/chargebee/v4/models/event/SubscriptionCanceledWithBackdatingEvent.java index d9841dce..a85cba5e 100644 --- a/src/main/java/com/chargebee/v4/models/event/SubscriptionCanceledWithBackdatingEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/SubscriptionCanceledWithBackdatingEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import java.util.List; import com.chargebee.v4.models.customer.Customer; @@ -66,25 +67,29 @@ public Content getContent() { } public static SubscriptionCanceledWithBackdatingEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static SubscriptionCanceledWithBackdatingEvent fromJson(JsonObject jsonObj) { SubscriptionCanceledWithBackdatingEvent obj = new SubscriptionCanceledWithBackdatingEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -169,37 +174,38 @@ public List getUnbilledCharges() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __subscriptionJson = JsonUtil.getObject(json, "subscription"); - if (__subscriptionJson != null) { - obj.subscription = Subscription.fromJson(__subscriptionJson); + JsonObject __subscriptionObj = JsonUtil.getJsonObject(jsonObj, "subscription"); + if (__subscriptionObj != null) { + obj.subscription = Subscription.fromJson(__subscriptionObj); } - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - obj.customer = Customer.fromJson(__customerJson); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + obj.customer = Customer.fromJson(__customerObj); } - String __cardJson = JsonUtil.getObject(json, "card"); - if (__cardJson != null) { - obj.card = Card.fromJson(__cardJson); + JsonObject __cardObj = JsonUtil.getJsonObject(jsonObj, "card"); + if (__cardObj != null) { + obj.card = Card.fromJson(__cardObj); } - String __invoiceJson = JsonUtil.getObject(json, "invoice"); - if (__invoiceJson != null) { - obj.invoice = Invoice.fromJson(__invoiceJson); + JsonObject __invoiceObj = JsonUtil.getJsonObject(jsonObj, "invoice"); + if (__invoiceObj != null) { + obj.invoice = Invoice.fromJson(__invoiceObj); } obj.creditNotes = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "credit_notes")).stream() - .map(CreditNote::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "credit_notes"), CreditNote::fromJson); obj.unbilledCharges = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "unbilled_charges")).stream() - .map(UnbilledCharge::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "unbilled_charges"), UnbilledCharge::fromJson); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/event/SubscriptionCancellationReminderEvent.java b/src/main/java/com/chargebee/v4/models/event/SubscriptionCancellationReminderEvent.java index 19180b7f..a2558a24 100644 --- a/src/main/java/com/chargebee/v4/models/event/SubscriptionCancellationReminderEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/SubscriptionCancellationReminderEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.customer.Customer; @@ -61,25 +62,29 @@ public Content getContent() { } public static SubscriptionCancellationReminderEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static SubscriptionCancellationReminderEvent fromJson(JsonObject jsonObj) { SubscriptionCancellationReminderEvent obj = new SubscriptionCancellationReminderEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -154,26 +159,31 @@ public AdvanceInvoiceSchedule getAdvanceInvoiceSchedule() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __subscriptionJson = JsonUtil.getObject(json, "subscription"); - if (__subscriptionJson != null) { - obj.subscription = Subscription.fromJson(__subscriptionJson); + JsonObject __subscriptionObj = JsonUtil.getJsonObject(jsonObj, "subscription"); + if (__subscriptionObj != null) { + obj.subscription = Subscription.fromJson(__subscriptionObj); } - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - obj.customer = Customer.fromJson(__customerJson); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + obj.customer = Customer.fromJson(__customerObj); } - String __cardJson = JsonUtil.getObject(json, "card"); - if (__cardJson != null) { - obj.card = Card.fromJson(__cardJson); + JsonObject __cardObj = JsonUtil.getJsonObject(jsonObj, "card"); + if (__cardObj != null) { + obj.card = Card.fromJson(__cardObj); } - String __advanceInvoiceScheduleJson = JsonUtil.getObject(json, "advance_invoice_schedule"); - if (__advanceInvoiceScheduleJson != null) { - obj.advanceInvoiceSchedule = AdvanceInvoiceSchedule.fromJson(__advanceInvoiceScheduleJson); + JsonObject __advanceInvoiceScheduleObj = + JsonUtil.getJsonObject(jsonObj, "advance_invoice_schedule"); + if (__advanceInvoiceScheduleObj != null) { + obj.advanceInvoiceSchedule = AdvanceInvoiceSchedule.fromJson(__advanceInvoiceScheduleObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/SubscriptionCancellationScheduledEvent.java b/src/main/java/com/chargebee/v4/models/event/SubscriptionCancellationScheduledEvent.java index 2766738d..6e4c1d6e 100644 --- a/src/main/java/com/chargebee/v4/models/event/SubscriptionCancellationScheduledEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/SubscriptionCancellationScheduledEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.customer.Customer; @@ -61,25 +62,29 @@ public Content getContent() { } public static SubscriptionCancellationScheduledEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static SubscriptionCancellationScheduledEvent fromJson(JsonObject jsonObj) { SubscriptionCancellationScheduledEvent obj = new SubscriptionCancellationScheduledEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -154,26 +159,31 @@ public AdvanceInvoiceSchedule getAdvanceInvoiceSchedule() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __subscriptionJson = JsonUtil.getObject(json, "subscription"); - if (__subscriptionJson != null) { - obj.subscription = Subscription.fromJson(__subscriptionJson); + JsonObject __subscriptionObj = JsonUtil.getJsonObject(jsonObj, "subscription"); + if (__subscriptionObj != null) { + obj.subscription = Subscription.fromJson(__subscriptionObj); } - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - obj.customer = Customer.fromJson(__customerJson); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + obj.customer = Customer.fromJson(__customerObj); } - String __cardJson = JsonUtil.getObject(json, "card"); - if (__cardJson != null) { - obj.card = Card.fromJson(__cardJson); + JsonObject __cardObj = JsonUtil.getJsonObject(jsonObj, "card"); + if (__cardObj != null) { + obj.card = Card.fromJson(__cardObj); } - String __advanceInvoiceScheduleJson = JsonUtil.getObject(json, "advance_invoice_schedule"); - if (__advanceInvoiceScheduleJson != null) { - obj.advanceInvoiceSchedule = AdvanceInvoiceSchedule.fromJson(__advanceInvoiceScheduleJson); + JsonObject __advanceInvoiceScheduleObj = + JsonUtil.getJsonObject(jsonObj, "advance_invoice_schedule"); + if (__advanceInvoiceScheduleObj != null) { + obj.advanceInvoiceSchedule = AdvanceInvoiceSchedule.fromJson(__advanceInvoiceScheduleObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/SubscriptionCancelledEvent.java b/src/main/java/com/chargebee/v4/models/event/SubscriptionCancelledEvent.java index 8909d82a..4f134043 100644 --- a/src/main/java/com/chargebee/v4/models/event/SubscriptionCancelledEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/SubscriptionCancelledEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import java.util.List; import com.chargebee.v4.models.customer.Customer; @@ -66,25 +67,29 @@ public Content getContent() { } public static SubscriptionCancelledEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static SubscriptionCancelledEvent fromJson(JsonObject jsonObj) { SubscriptionCancelledEvent obj = new SubscriptionCancelledEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -169,37 +174,38 @@ public List getUnbilledCharges() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __subscriptionJson = JsonUtil.getObject(json, "subscription"); - if (__subscriptionJson != null) { - obj.subscription = Subscription.fromJson(__subscriptionJson); + JsonObject __subscriptionObj = JsonUtil.getJsonObject(jsonObj, "subscription"); + if (__subscriptionObj != null) { + obj.subscription = Subscription.fromJson(__subscriptionObj); } - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - obj.customer = Customer.fromJson(__customerJson); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + obj.customer = Customer.fromJson(__customerObj); } - String __cardJson = JsonUtil.getObject(json, "card"); - if (__cardJson != null) { - obj.card = Card.fromJson(__cardJson); + JsonObject __cardObj = JsonUtil.getJsonObject(jsonObj, "card"); + if (__cardObj != null) { + obj.card = Card.fromJson(__cardObj); } - String __invoiceJson = JsonUtil.getObject(json, "invoice"); - if (__invoiceJson != null) { - obj.invoice = Invoice.fromJson(__invoiceJson); + JsonObject __invoiceObj = JsonUtil.getJsonObject(jsonObj, "invoice"); + if (__invoiceObj != null) { + obj.invoice = Invoice.fromJson(__invoiceObj); } obj.creditNotes = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "credit_notes")).stream() - .map(CreditNote::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "credit_notes"), CreditNote::fromJson); obj.unbilledCharges = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "unbilled_charges")).stream() - .map(UnbilledCharge::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "unbilled_charges"), UnbilledCharge::fromJson); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/event/SubscriptionChangedEvent.java b/src/main/java/com/chargebee/v4/models/event/SubscriptionChangedEvent.java index 93606860..ee6b27ea 100644 --- a/src/main/java/com/chargebee/v4/models/event/SubscriptionChangedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/SubscriptionChangedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import java.util.List; import com.chargebee.v4.models.customer.Customer; @@ -66,25 +67,29 @@ public Content getContent() { } public static SubscriptionChangedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static SubscriptionChangedEvent fromJson(JsonObject jsonObj) { SubscriptionChangedEvent obj = new SubscriptionChangedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -169,37 +174,38 @@ public List getUnbilledCharges() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __subscriptionJson = JsonUtil.getObject(json, "subscription"); - if (__subscriptionJson != null) { - obj.subscription = Subscription.fromJson(__subscriptionJson); + JsonObject __subscriptionObj = JsonUtil.getJsonObject(jsonObj, "subscription"); + if (__subscriptionObj != null) { + obj.subscription = Subscription.fromJson(__subscriptionObj); } - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - obj.customer = Customer.fromJson(__customerJson); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + obj.customer = Customer.fromJson(__customerObj); } - String __cardJson = JsonUtil.getObject(json, "card"); - if (__cardJson != null) { - obj.card = Card.fromJson(__cardJson); + JsonObject __cardObj = JsonUtil.getJsonObject(jsonObj, "card"); + if (__cardObj != null) { + obj.card = Card.fromJson(__cardObj); } - String __invoiceJson = JsonUtil.getObject(json, "invoice"); - if (__invoiceJson != null) { - obj.invoice = Invoice.fromJson(__invoiceJson); + JsonObject __invoiceObj = JsonUtil.getJsonObject(jsonObj, "invoice"); + if (__invoiceObj != null) { + obj.invoice = Invoice.fromJson(__invoiceObj); } obj.creditNotes = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "credit_notes")).stream() - .map(CreditNote::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "credit_notes"), CreditNote::fromJson); obj.unbilledCharges = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "unbilled_charges")).stream() - .map(UnbilledCharge::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "unbilled_charges"), UnbilledCharge::fromJson); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/event/SubscriptionChangedWithBackdatingEvent.java b/src/main/java/com/chargebee/v4/models/event/SubscriptionChangedWithBackdatingEvent.java index 47e2d5c9..3718b0b9 100644 --- a/src/main/java/com/chargebee/v4/models/event/SubscriptionChangedWithBackdatingEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/SubscriptionChangedWithBackdatingEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import java.util.List; import com.chargebee.v4.models.customer.Customer; @@ -66,25 +67,29 @@ public Content getContent() { } public static SubscriptionChangedWithBackdatingEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static SubscriptionChangedWithBackdatingEvent fromJson(JsonObject jsonObj) { SubscriptionChangedWithBackdatingEvent obj = new SubscriptionChangedWithBackdatingEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -169,37 +174,38 @@ public List getUnbilledCharges() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __subscriptionJson = JsonUtil.getObject(json, "subscription"); - if (__subscriptionJson != null) { - obj.subscription = Subscription.fromJson(__subscriptionJson); + JsonObject __subscriptionObj = JsonUtil.getJsonObject(jsonObj, "subscription"); + if (__subscriptionObj != null) { + obj.subscription = Subscription.fromJson(__subscriptionObj); } - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - obj.customer = Customer.fromJson(__customerJson); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + obj.customer = Customer.fromJson(__customerObj); } - String __cardJson = JsonUtil.getObject(json, "card"); - if (__cardJson != null) { - obj.card = Card.fromJson(__cardJson); + JsonObject __cardObj = JsonUtil.getJsonObject(jsonObj, "card"); + if (__cardObj != null) { + obj.card = Card.fromJson(__cardObj); } - String __invoiceJson = JsonUtil.getObject(json, "invoice"); - if (__invoiceJson != null) { - obj.invoice = Invoice.fromJson(__invoiceJson); + JsonObject __invoiceObj = JsonUtil.getJsonObject(jsonObj, "invoice"); + if (__invoiceObj != null) { + obj.invoice = Invoice.fromJson(__invoiceObj); } obj.creditNotes = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "credit_notes")).stream() - .map(CreditNote::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "credit_notes"), CreditNote::fromJson); obj.unbilledCharges = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "unbilled_charges")).stream() - .map(UnbilledCharge::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "unbilled_charges"), UnbilledCharge::fromJson); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/event/SubscriptionChangesScheduledEvent.java b/src/main/java/com/chargebee/v4/models/event/SubscriptionChangesScheduledEvent.java index c1377d9b..abf02d55 100644 --- a/src/main/java/com/chargebee/v4/models/event/SubscriptionChangesScheduledEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/SubscriptionChangesScheduledEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.customer.Customer; @@ -61,25 +62,29 @@ public Content getContent() { } public static SubscriptionChangesScheduledEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static SubscriptionChangesScheduledEvent fromJson(JsonObject jsonObj) { SubscriptionChangesScheduledEvent obj = new SubscriptionChangesScheduledEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -154,26 +159,31 @@ public AdvanceInvoiceSchedule getAdvanceInvoiceSchedule() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __subscriptionJson = JsonUtil.getObject(json, "subscription"); - if (__subscriptionJson != null) { - obj.subscription = Subscription.fromJson(__subscriptionJson); + JsonObject __subscriptionObj = JsonUtil.getJsonObject(jsonObj, "subscription"); + if (__subscriptionObj != null) { + obj.subscription = Subscription.fromJson(__subscriptionObj); } - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - obj.customer = Customer.fromJson(__customerJson); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + obj.customer = Customer.fromJson(__customerObj); } - String __cardJson = JsonUtil.getObject(json, "card"); - if (__cardJson != null) { - obj.card = Card.fromJson(__cardJson); + JsonObject __cardObj = JsonUtil.getJsonObject(jsonObj, "card"); + if (__cardObj != null) { + obj.card = Card.fromJson(__cardObj); } - String __advanceInvoiceScheduleJson = JsonUtil.getObject(json, "advance_invoice_schedule"); - if (__advanceInvoiceScheduleJson != null) { - obj.advanceInvoiceSchedule = AdvanceInvoiceSchedule.fromJson(__advanceInvoiceScheduleJson); + JsonObject __advanceInvoiceScheduleObj = + JsonUtil.getJsonObject(jsonObj, "advance_invoice_schedule"); + if (__advanceInvoiceScheduleObj != null) { + obj.advanceInvoiceSchedule = AdvanceInvoiceSchedule.fromJson(__advanceInvoiceScheduleObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/SubscriptionCreatedEvent.java b/src/main/java/com/chargebee/v4/models/event/SubscriptionCreatedEvent.java index 80075711..7c282eab 100644 --- a/src/main/java/com/chargebee/v4/models/event/SubscriptionCreatedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/SubscriptionCreatedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import java.util.List; import com.chargebee.v4.models.customer.Customer; @@ -64,25 +65,29 @@ public Content getContent() { } public static SubscriptionCreatedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static SubscriptionCreatedEvent fromJson(JsonObject jsonObj) { SubscriptionCreatedEvent obj = new SubscriptionCreatedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -162,32 +167,35 @@ public List getUnbilledCharges() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __subscriptionJson = JsonUtil.getObject(json, "subscription"); - if (__subscriptionJson != null) { - obj.subscription = Subscription.fromJson(__subscriptionJson); + JsonObject __subscriptionObj = JsonUtil.getJsonObject(jsonObj, "subscription"); + if (__subscriptionObj != null) { + obj.subscription = Subscription.fromJson(__subscriptionObj); } - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - obj.customer = Customer.fromJson(__customerJson); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + obj.customer = Customer.fromJson(__customerObj); } - String __cardJson = JsonUtil.getObject(json, "card"); - if (__cardJson != null) { - obj.card = Card.fromJson(__cardJson); + JsonObject __cardObj = JsonUtil.getJsonObject(jsonObj, "card"); + if (__cardObj != null) { + obj.card = Card.fromJson(__cardObj); } - String __invoiceJson = JsonUtil.getObject(json, "invoice"); - if (__invoiceJson != null) { - obj.invoice = Invoice.fromJson(__invoiceJson); + JsonObject __invoiceObj = JsonUtil.getJsonObject(jsonObj, "invoice"); + if (__invoiceObj != null) { + obj.invoice = Invoice.fromJson(__invoiceObj); } obj.unbilledCharges = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "unbilled_charges")).stream() - .map(UnbilledCharge::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "unbilled_charges"), UnbilledCharge::fromJson); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/event/SubscriptionCreatedWithBackdatingEvent.java b/src/main/java/com/chargebee/v4/models/event/SubscriptionCreatedWithBackdatingEvent.java index 0d08477b..df5045cf 100644 --- a/src/main/java/com/chargebee/v4/models/event/SubscriptionCreatedWithBackdatingEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/SubscriptionCreatedWithBackdatingEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import java.util.List; import com.chargebee.v4.models.customer.Customer; @@ -64,25 +65,29 @@ public Content getContent() { } public static SubscriptionCreatedWithBackdatingEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static SubscriptionCreatedWithBackdatingEvent fromJson(JsonObject jsonObj) { SubscriptionCreatedWithBackdatingEvent obj = new SubscriptionCreatedWithBackdatingEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -162,32 +167,35 @@ public List getUnbilledCharges() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __subscriptionJson = JsonUtil.getObject(json, "subscription"); - if (__subscriptionJson != null) { - obj.subscription = Subscription.fromJson(__subscriptionJson); + JsonObject __subscriptionObj = JsonUtil.getJsonObject(jsonObj, "subscription"); + if (__subscriptionObj != null) { + obj.subscription = Subscription.fromJson(__subscriptionObj); } - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - obj.customer = Customer.fromJson(__customerJson); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + obj.customer = Customer.fromJson(__customerObj); } - String __cardJson = JsonUtil.getObject(json, "card"); - if (__cardJson != null) { - obj.card = Card.fromJson(__cardJson); + JsonObject __cardObj = JsonUtil.getJsonObject(jsonObj, "card"); + if (__cardObj != null) { + obj.card = Card.fromJson(__cardObj); } - String __invoiceJson = JsonUtil.getObject(json, "invoice"); - if (__invoiceJson != null) { - obj.invoice = Invoice.fromJson(__invoiceJson); + JsonObject __invoiceObj = JsonUtil.getJsonObject(jsonObj, "invoice"); + if (__invoiceObj != null) { + obj.invoice = Invoice.fromJson(__invoiceObj); } obj.unbilledCharges = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "unbilled_charges")).stream() - .map(UnbilledCharge::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "unbilled_charges"), UnbilledCharge::fromJson); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/event/SubscriptionDeletedEvent.java b/src/main/java/com/chargebee/v4/models/event/SubscriptionDeletedEvent.java index 64975544..096b587b 100644 --- a/src/main/java/com/chargebee/v4/models/event/SubscriptionDeletedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/SubscriptionDeletedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.customer.Customer; @@ -61,25 +62,29 @@ public Content getContent() { } public static SubscriptionDeletedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static SubscriptionDeletedEvent fromJson(JsonObject jsonObj) { SubscriptionDeletedEvent obj = new SubscriptionDeletedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -154,26 +159,31 @@ public AdvanceInvoiceSchedule getAdvanceInvoiceSchedule() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __subscriptionJson = JsonUtil.getObject(json, "subscription"); - if (__subscriptionJson != null) { - obj.subscription = Subscription.fromJson(__subscriptionJson); + JsonObject __subscriptionObj = JsonUtil.getJsonObject(jsonObj, "subscription"); + if (__subscriptionObj != null) { + obj.subscription = Subscription.fromJson(__subscriptionObj); } - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - obj.customer = Customer.fromJson(__customerJson); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + obj.customer = Customer.fromJson(__customerObj); } - String __cardJson = JsonUtil.getObject(json, "card"); - if (__cardJson != null) { - obj.card = Card.fromJson(__cardJson); + JsonObject __cardObj = JsonUtil.getJsonObject(jsonObj, "card"); + if (__cardObj != null) { + obj.card = Card.fromJson(__cardObj); } - String __advanceInvoiceScheduleJson = JsonUtil.getObject(json, "advance_invoice_schedule"); - if (__advanceInvoiceScheduleJson != null) { - obj.advanceInvoiceSchedule = AdvanceInvoiceSchedule.fromJson(__advanceInvoiceScheduleJson); + JsonObject __advanceInvoiceScheduleObj = + JsonUtil.getJsonObject(jsonObj, "advance_invoice_schedule"); + if (__advanceInvoiceScheduleObj != null) { + obj.advanceInvoiceSchedule = AdvanceInvoiceSchedule.fromJson(__advanceInvoiceScheduleObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/SubscriptionEntitlementsCreatedEvent.java b/src/main/java/com/chargebee/v4/models/event/SubscriptionEntitlementsCreatedEvent.java index e7029cf8..41038f76 100644 --- a/src/main/java/com/chargebee/v4/models/event/SubscriptionEntitlementsCreatedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/SubscriptionEntitlementsCreatedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.subscriptionEntitlementsCreatedDetail.SubscriptionEntitlementsCreatedDetail; @@ -55,25 +56,29 @@ public Content getContent() { } public static SubscriptionEntitlementsCreatedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static SubscriptionEntitlementsCreatedEvent fromJson(JsonObject jsonObj) { SubscriptionEntitlementsCreatedEvent obj = new SubscriptionEntitlementsCreatedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -133,14 +138,18 @@ public SubscriptionEntitlementsCreatedDetail getSubscriptionEntitlementsCreatedD } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __subscriptionEntitlementsCreatedDetailJson = - JsonUtil.getObject(json, "subscription_entitlements_created_detail"); - if (__subscriptionEntitlementsCreatedDetailJson != null) { + JsonObject __subscriptionEntitlementsCreatedDetailObj = + JsonUtil.getJsonObject(jsonObj, "subscription_entitlements_created_detail"); + if (__subscriptionEntitlementsCreatedDetailObj != null) { obj.subscriptionEntitlementsCreatedDetail = SubscriptionEntitlementsCreatedDetail.fromJson( - __subscriptionEntitlementsCreatedDetailJson); + __subscriptionEntitlementsCreatedDetailObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/SubscriptionEntitlementsUpdatedEvent.java b/src/main/java/com/chargebee/v4/models/event/SubscriptionEntitlementsUpdatedEvent.java index 41a2d4bb..5b8687eb 100644 --- a/src/main/java/com/chargebee/v4/models/event/SubscriptionEntitlementsUpdatedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/SubscriptionEntitlementsUpdatedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.subscriptionEntitlementsUpdatedDetail.SubscriptionEntitlementsUpdatedDetail; @@ -55,25 +56,29 @@ public Content getContent() { } public static SubscriptionEntitlementsUpdatedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static SubscriptionEntitlementsUpdatedEvent fromJson(JsonObject jsonObj) { SubscriptionEntitlementsUpdatedEvent obj = new SubscriptionEntitlementsUpdatedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -133,14 +138,18 @@ public SubscriptionEntitlementsUpdatedDetail getSubscriptionEntitlementsUpdatedD } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __subscriptionEntitlementsUpdatedDetailJson = - JsonUtil.getObject(json, "subscription_entitlements_updated_detail"); - if (__subscriptionEntitlementsUpdatedDetailJson != null) { + JsonObject __subscriptionEntitlementsUpdatedDetailObj = + JsonUtil.getJsonObject(jsonObj, "subscription_entitlements_updated_detail"); + if (__subscriptionEntitlementsUpdatedDetailObj != null) { obj.subscriptionEntitlementsUpdatedDetail = SubscriptionEntitlementsUpdatedDetail.fromJson( - __subscriptionEntitlementsUpdatedDetailJson); + __subscriptionEntitlementsUpdatedDetailObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/SubscriptionItemsRenewedEvent.java b/src/main/java/com/chargebee/v4/models/event/SubscriptionItemsRenewedEvent.java index 206fb304..05e79024 100644 --- a/src/main/java/com/chargebee/v4/models/event/SubscriptionItemsRenewedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/SubscriptionItemsRenewedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import java.util.List; import com.chargebee.v4.models.customer.Customer; @@ -66,25 +67,29 @@ public Content getContent() { } public static SubscriptionItemsRenewedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static SubscriptionItemsRenewedEvent fromJson(JsonObject jsonObj) { SubscriptionItemsRenewedEvent obj = new SubscriptionItemsRenewedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -169,37 +174,38 @@ public List getUnbilledCharges() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __subscriptionJson = JsonUtil.getObject(json, "subscription"); - if (__subscriptionJson != null) { - obj.subscription = Subscription.fromJson(__subscriptionJson); + JsonObject __subscriptionObj = JsonUtil.getJsonObject(jsonObj, "subscription"); + if (__subscriptionObj != null) { + obj.subscription = Subscription.fromJson(__subscriptionObj); } - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - obj.customer = Customer.fromJson(__customerJson); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + obj.customer = Customer.fromJson(__customerObj); } - String __cardJson = JsonUtil.getObject(json, "card"); - if (__cardJson != null) { - obj.card = Card.fromJson(__cardJson); + JsonObject __cardObj = JsonUtil.getJsonObject(jsonObj, "card"); + if (__cardObj != null) { + obj.card = Card.fromJson(__cardObj); } - String __invoiceJson = JsonUtil.getObject(json, "invoice"); - if (__invoiceJson != null) { - obj.invoice = Invoice.fromJson(__invoiceJson); + JsonObject __invoiceObj = JsonUtil.getJsonObject(jsonObj, "invoice"); + if (__invoiceObj != null) { + obj.invoice = Invoice.fromJson(__invoiceObj); } obj.creditNotes = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "credit_notes")).stream() - .map(CreditNote::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "credit_notes"), CreditNote::fromJson); obj.unbilledCharges = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "unbilled_charges")).stream() - .map(UnbilledCharge::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "unbilled_charges"), UnbilledCharge::fromJson); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/event/SubscriptionMovedInEvent.java b/src/main/java/com/chargebee/v4/models/event/SubscriptionMovedInEvent.java index 741acae3..4ac0b100 100644 --- a/src/main/java/com/chargebee/v4/models/event/SubscriptionMovedInEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/SubscriptionMovedInEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.subscription.Subscription; @@ -55,25 +56,29 @@ public Content getContent() { } public static SubscriptionMovedInEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static SubscriptionMovedInEvent fromJson(JsonObject jsonObj) { SubscriptionMovedInEvent obj = new SubscriptionMovedInEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -133,11 +138,15 @@ public Subscription getSubscription() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __subscriptionJson = JsonUtil.getObject(json, "subscription"); - if (__subscriptionJson != null) { - obj.subscription = Subscription.fromJson(__subscriptionJson); + JsonObject __subscriptionObj = JsonUtil.getJsonObject(jsonObj, "subscription"); + if (__subscriptionObj != null) { + obj.subscription = Subscription.fromJson(__subscriptionObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/SubscriptionMovedOutEvent.java b/src/main/java/com/chargebee/v4/models/event/SubscriptionMovedOutEvent.java index 4b5737e9..d8644bd1 100644 --- a/src/main/java/com/chargebee/v4/models/event/SubscriptionMovedOutEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/SubscriptionMovedOutEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.subscription.Subscription; @@ -55,25 +56,29 @@ public Content getContent() { } public static SubscriptionMovedOutEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static SubscriptionMovedOutEvent fromJson(JsonObject jsonObj) { SubscriptionMovedOutEvent obj = new SubscriptionMovedOutEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -133,11 +138,15 @@ public Subscription getSubscription() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __subscriptionJson = JsonUtil.getObject(json, "subscription"); - if (__subscriptionJson != null) { - obj.subscription = Subscription.fromJson(__subscriptionJson); + JsonObject __subscriptionObj = JsonUtil.getJsonObject(jsonObj, "subscription"); + if (__subscriptionObj != null) { + obj.subscription = Subscription.fromJson(__subscriptionObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/SubscriptionMovementFailedEvent.java b/src/main/java/com/chargebee/v4/models/event/SubscriptionMovementFailedEvent.java index 6219b437..2084ba61 100644 --- a/src/main/java/com/chargebee/v4/models/event/SubscriptionMovementFailedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/SubscriptionMovementFailedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.subscription.Subscription; @@ -55,25 +56,29 @@ public Content getContent() { } public static SubscriptionMovementFailedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static SubscriptionMovementFailedEvent fromJson(JsonObject jsonObj) { SubscriptionMovementFailedEvent obj = new SubscriptionMovementFailedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -133,11 +138,15 @@ public Subscription getSubscription() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __subscriptionJson = JsonUtil.getObject(json, "subscription"); - if (__subscriptionJson != null) { - obj.subscription = Subscription.fromJson(__subscriptionJson); + JsonObject __subscriptionObj = JsonUtil.getJsonObject(jsonObj, "subscription"); + if (__subscriptionObj != null) { + obj.subscription = Subscription.fromJson(__subscriptionObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/SubscriptionPauseScheduledEvent.java b/src/main/java/com/chargebee/v4/models/event/SubscriptionPauseScheduledEvent.java index 9a4536bb..4b2dbab4 100644 --- a/src/main/java/com/chargebee/v4/models/event/SubscriptionPauseScheduledEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/SubscriptionPauseScheduledEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.customer.Customer; @@ -61,25 +62,29 @@ public Content getContent() { } public static SubscriptionPauseScheduledEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static SubscriptionPauseScheduledEvent fromJson(JsonObject jsonObj) { SubscriptionPauseScheduledEvent obj = new SubscriptionPauseScheduledEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -154,26 +159,31 @@ public AdvanceInvoiceSchedule getAdvanceInvoiceSchedule() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __subscriptionJson = JsonUtil.getObject(json, "subscription"); - if (__subscriptionJson != null) { - obj.subscription = Subscription.fromJson(__subscriptionJson); + JsonObject __subscriptionObj = JsonUtil.getJsonObject(jsonObj, "subscription"); + if (__subscriptionObj != null) { + obj.subscription = Subscription.fromJson(__subscriptionObj); } - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - obj.customer = Customer.fromJson(__customerJson); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + obj.customer = Customer.fromJson(__customerObj); } - String __cardJson = JsonUtil.getObject(json, "card"); - if (__cardJson != null) { - obj.card = Card.fromJson(__cardJson); + JsonObject __cardObj = JsonUtil.getJsonObject(jsonObj, "card"); + if (__cardObj != null) { + obj.card = Card.fromJson(__cardObj); } - String __advanceInvoiceScheduleJson = JsonUtil.getObject(json, "advance_invoice_schedule"); - if (__advanceInvoiceScheduleJson != null) { - obj.advanceInvoiceSchedule = AdvanceInvoiceSchedule.fromJson(__advanceInvoiceScheduleJson); + JsonObject __advanceInvoiceScheduleObj = + JsonUtil.getJsonObject(jsonObj, "advance_invoice_schedule"); + if (__advanceInvoiceScheduleObj != null) { + obj.advanceInvoiceSchedule = AdvanceInvoiceSchedule.fromJson(__advanceInvoiceScheduleObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/SubscriptionPausedEvent.java b/src/main/java/com/chargebee/v4/models/event/SubscriptionPausedEvent.java index c8f772dc..3b1994c1 100644 --- a/src/main/java/com/chargebee/v4/models/event/SubscriptionPausedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/SubscriptionPausedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import java.util.List; import com.chargebee.v4.models.customer.Customer; @@ -66,25 +67,29 @@ public Content getContent() { } public static SubscriptionPausedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static SubscriptionPausedEvent fromJson(JsonObject jsonObj) { SubscriptionPausedEvent obj = new SubscriptionPausedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -169,37 +174,38 @@ public List getUnbilledCharges() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __subscriptionJson = JsonUtil.getObject(json, "subscription"); - if (__subscriptionJson != null) { - obj.subscription = Subscription.fromJson(__subscriptionJson); + JsonObject __subscriptionObj = JsonUtil.getJsonObject(jsonObj, "subscription"); + if (__subscriptionObj != null) { + obj.subscription = Subscription.fromJson(__subscriptionObj); } - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - obj.customer = Customer.fromJson(__customerJson); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + obj.customer = Customer.fromJson(__customerObj); } - String __cardJson = JsonUtil.getObject(json, "card"); - if (__cardJson != null) { - obj.card = Card.fromJson(__cardJson); + JsonObject __cardObj = JsonUtil.getJsonObject(jsonObj, "card"); + if (__cardObj != null) { + obj.card = Card.fromJson(__cardObj); } - String __invoiceJson = JsonUtil.getObject(json, "invoice"); - if (__invoiceJson != null) { - obj.invoice = Invoice.fromJson(__invoiceJson); + JsonObject __invoiceObj = JsonUtil.getJsonObject(jsonObj, "invoice"); + if (__invoiceObj != null) { + obj.invoice = Invoice.fromJson(__invoiceObj); } obj.creditNotes = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "credit_notes")).stream() - .map(CreditNote::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "credit_notes"), CreditNote::fromJson); obj.unbilledCharges = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "unbilled_charges")).stream() - .map(UnbilledCharge::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "unbilled_charges"), UnbilledCharge::fromJson); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/event/SubscriptionRampAppliedEvent.java b/src/main/java/com/chargebee/v4/models/event/SubscriptionRampAppliedEvent.java index 82f8f947..72f755ea 100644 --- a/src/main/java/com/chargebee/v4/models/event/SubscriptionRampAppliedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/SubscriptionRampAppliedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.ramp.Ramp; @@ -55,25 +56,29 @@ public Content getContent() { } public static SubscriptionRampAppliedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static SubscriptionRampAppliedEvent fromJson(JsonObject jsonObj) { SubscriptionRampAppliedEvent obj = new SubscriptionRampAppliedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -133,11 +138,15 @@ public Ramp getRamp() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __rampJson = JsonUtil.getObject(json, "ramp"); - if (__rampJson != null) { - obj.ramp = Ramp.fromJson(__rampJson); + JsonObject __rampObj = JsonUtil.getJsonObject(jsonObj, "ramp"); + if (__rampObj != null) { + obj.ramp = Ramp.fromJson(__rampObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/SubscriptionRampCreatedEvent.java b/src/main/java/com/chargebee/v4/models/event/SubscriptionRampCreatedEvent.java index 7bd39584..1d8d773a 100644 --- a/src/main/java/com/chargebee/v4/models/event/SubscriptionRampCreatedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/SubscriptionRampCreatedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.ramp.Ramp; @@ -55,25 +56,29 @@ public Content getContent() { } public static SubscriptionRampCreatedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static SubscriptionRampCreatedEvent fromJson(JsonObject jsonObj) { SubscriptionRampCreatedEvent obj = new SubscriptionRampCreatedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -133,11 +138,15 @@ public Ramp getRamp() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __rampJson = JsonUtil.getObject(json, "ramp"); - if (__rampJson != null) { - obj.ramp = Ramp.fromJson(__rampJson); + JsonObject __rampObj = JsonUtil.getJsonObject(jsonObj, "ramp"); + if (__rampObj != null) { + obj.ramp = Ramp.fromJson(__rampObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/SubscriptionRampDeletedEvent.java b/src/main/java/com/chargebee/v4/models/event/SubscriptionRampDeletedEvent.java index a1232d1a..fccc8b25 100644 --- a/src/main/java/com/chargebee/v4/models/event/SubscriptionRampDeletedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/SubscriptionRampDeletedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.ramp.Ramp; @@ -55,25 +56,29 @@ public Content getContent() { } public static SubscriptionRampDeletedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static SubscriptionRampDeletedEvent fromJson(JsonObject jsonObj) { SubscriptionRampDeletedEvent obj = new SubscriptionRampDeletedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -133,11 +138,15 @@ public Ramp getRamp() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __rampJson = JsonUtil.getObject(json, "ramp"); - if (__rampJson != null) { - obj.ramp = Ramp.fromJson(__rampJson); + JsonObject __rampObj = JsonUtil.getJsonObject(jsonObj, "ramp"); + if (__rampObj != null) { + obj.ramp = Ramp.fromJson(__rampObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/SubscriptionRampDraftedEvent.java b/src/main/java/com/chargebee/v4/models/event/SubscriptionRampDraftedEvent.java index 74033716..523ee81b 100644 --- a/src/main/java/com/chargebee/v4/models/event/SubscriptionRampDraftedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/SubscriptionRampDraftedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.ramp.Ramp; @@ -55,25 +56,29 @@ public Content getContent() { } public static SubscriptionRampDraftedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static SubscriptionRampDraftedEvent fromJson(JsonObject jsonObj) { SubscriptionRampDraftedEvent obj = new SubscriptionRampDraftedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -133,11 +138,15 @@ public Ramp getRamp() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __rampJson = JsonUtil.getObject(json, "ramp"); - if (__rampJson != null) { - obj.ramp = Ramp.fromJson(__rampJson); + JsonObject __rampObj = JsonUtil.getJsonObject(jsonObj, "ramp"); + if (__rampObj != null) { + obj.ramp = Ramp.fromJson(__rampObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/SubscriptionRampUpdatedEvent.java b/src/main/java/com/chargebee/v4/models/event/SubscriptionRampUpdatedEvent.java index c08df937..f95bf7ad 100644 --- a/src/main/java/com/chargebee/v4/models/event/SubscriptionRampUpdatedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/SubscriptionRampUpdatedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.ramp.Ramp; @@ -55,25 +56,29 @@ public Content getContent() { } public static SubscriptionRampUpdatedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static SubscriptionRampUpdatedEvent fromJson(JsonObject jsonObj) { SubscriptionRampUpdatedEvent obj = new SubscriptionRampUpdatedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -133,11 +138,15 @@ public Ramp getRamp() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __rampJson = JsonUtil.getObject(json, "ramp"); - if (__rampJson != null) { - obj.ramp = Ramp.fromJson(__rampJson); + JsonObject __rampObj = JsonUtil.getJsonObject(jsonObj, "ramp"); + if (__rampObj != null) { + obj.ramp = Ramp.fromJson(__rampObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/SubscriptionReactivatedEvent.java b/src/main/java/com/chargebee/v4/models/event/SubscriptionReactivatedEvent.java index bb2d8eb2..9e7b7f8f 100644 --- a/src/main/java/com/chargebee/v4/models/event/SubscriptionReactivatedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/SubscriptionReactivatedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import java.util.List; import com.chargebee.v4.models.customer.Customer; @@ -64,25 +65,29 @@ public Content getContent() { } public static SubscriptionReactivatedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static SubscriptionReactivatedEvent fromJson(JsonObject jsonObj) { SubscriptionReactivatedEvent obj = new SubscriptionReactivatedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -162,32 +167,35 @@ public List getUnbilledCharges() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __subscriptionJson = JsonUtil.getObject(json, "subscription"); - if (__subscriptionJson != null) { - obj.subscription = Subscription.fromJson(__subscriptionJson); + JsonObject __subscriptionObj = JsonUtil.getJsonObject(jsonObj, "subscription"); + if (__subscriptionObj != null) { + obj.subscription = Subscription.fromJson(__subscriptionObj); } - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - obj.customer = Customer.fromJson(__customerJson); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + obj.customer = Customer.fromJson(__customerObj); } - String __cardJson = JsonUtil.getObject(json, "card"); - if (__cardJson != null) { - obj.card = Card.fromJson(__cardJson); + JsonObject __cardObj = JsonUtil.getJsonObject(jsonObj, "card"); + if (__cardObj != null) { + obj.card = Card.fromJson(__cardObj); } - String __invoiceJson = JsonUtil.getObject(json, "invoice"); - if (__invoiceJson != null) { - obj.invoice = Invoice.fromJson(__invoiceJson); + JsonObject __invoiceObj = JsonUtil.getJsonObject(jsonObj, "invoice"); + if (__invoiceObj != null) { + obj.invoice = Invoice.fromJson(__invoiceObj); } obj.unbilledCharges = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "unbilled_charges")).stream() - .map(UnbilledCharge::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "unbilled_charges"), UnbilledCharge::fromJson); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/event/SubscriptionReactivatedWithBackdatingEvent.java b/src/main/java/com/chargebee/v4/models/event/SubscriptionReactivatedWithBackdatingEvent.java index 9dbf9bc7..ad890071 100644 --- a/src/main/java/com/chargebee/v4/models/event/SubscriptionReactivatedWithBackdatingEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/SubscriptionReactivatedWithBackdatingEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import java.util.List; import com.chargebee.v4.models.customer.Customer; @@ -64,26 +65,30 @@ public Content getContent() { } public static SubscriptionReactivatedWithBackdatingEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static SubscriptionReactivatedWithBackdatingEvent fromJson(JsonObject jsonObj) { SubscriptionReactivatedWithBackdatingEvent obj = new SubscriptionReactivatedWithBackdatingEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -164,32 +169,35 @@ public List getUnbilledCharges() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __subscriptionJson = JsonUtil.getObject(json, "subscription"); - if (__subscriptionJson != null) { - obj.subscription = Subscription.fromJson(__subscriptionJson); + JsonObject __subscriptionObj = JsonUtil.getJsonObject(jsonObj, "subscription"); + if (__subscriptionObj != null) { + obj.subscription = Subscription.fromJson(__subscriptionObj); } - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - obj.customer = Customer.fromJson(__customerJson); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + obj.customer = Customer.fromJson(__customerObj); } - String __cardJson = JsonUtil.getObject(json, "card"); - if (__cardJson != null) { - obj.card = Card.fromJson(__cardJson); + JsonObject __cardObj = JsonUtil.getJsonObject(jsonObj, "card"); + if (__cardObj != null) { + obj.card = Card.fromJson(__cardObj); } - String __invoiceJson = JsonUtil.getObject(json, "invoice"); - if (__invoiceJson != null) { - obj.invoice = Invoice.fromJson(__invoiceJson); + JsonObject __invoiceObj = JsonUtil.getJsonObject(jsonObj, "invoice"); + if (__invoiceObj != null) { + obj.invoice = Invoice.fromJson(__invoiceObj); } obj.unbilledCharges = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "unbilled_charges")).stream() - .map(UnbilledCharge::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "unbilled_charges"), UnbilledCharge::fromJson); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/event/SubscriptionRenewalReminderEvent.java b/src/main/java/com/chargebee/v4/models/event/SubscriptionRenewalReminderEvent.java index eabc6a2d..6b0f168c 100644 --- a/src/main/java/com/chargebee/v4/models/event/SubscriptionRenewalReminderEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/SubscriptionRenewalReminderEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.customer.Customer; @@ -61,25 +62,29 @@ public Content getContent() { } public static SubscriptionRenewalReminderEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static SubscriptionRenewalReminderEvent fromJson(JsonObject jsonObj) { SubscriptionRenewalReminderEvent obj = new SubscriptionRenewalReminderEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -154,26 +159,31 @@ public AdvanceInvoiceSchedule getAdvanceInvoiceSchedule() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __subscriptionJson = JsonUtil.getObject(json, "subscription"); - if (__subscriptionJson != null) { - obj.subscription = Subscription.fromJson(__subscriptionJson); + JsonObject __subscriptionObj = JsonUtil.getJsonObject(jsonObj, "subscription"); + if (__subscriptionObj != null) { + obj.subscription = Subscription.fromJson(__subscriptionObj); } - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - obj.customer = Customer.fromJson(__customerJson); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + obj.customer = Customer.fromJson(__customerObj); } - String __cardJson = JsonUtil.getObject(json, "card"); - if (__cardJson != null) { - obj.card = Card.fromJson(__cardJson); + JsonObject __cardObj = JsonUtil.getJsonObject(jsonObj, "card"); + if (__cardObj != null) { + obj.card = Card.fromJson(__cardObj); } - String __advanceInvoiceScheduleJson = JsonUtil.getObject(json, "advance_invoice_schedule"); - if (__advanceInvoiceScheduleJson != null) { - obj.advanceInvoiceSchedule = AdvanceInvoiceSchedule.fromJson(__advanceInvoiceScheduleJson); + JsonObject __advanceInvoiceScheduleObj = + JsonUtil.getJsonObject(jsonObj, "advance_invoice_schedule"); + if (__advanceInvoiceScheduleObj != null) { + obj.advanceInvoiceSchedule = AdvanceInvoiceSchedule.fromJson(__advanceInvoiceScheduleObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/SubscriptionRenewedEvent.java b/src/main/java/com/chargebee/v4/models/event/SubscriptionRenewedEvent.java index df8eaf4d..5b9a6c2e 100644 --- a/src/main/java/com/chargebee/v4/models/event/SubscriptionRenewedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/SubscriptionRenewedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import java.util.List; import com.chargebee.v4.models.customer.Customer; @@ -64,25 +65,29 @@ public Content getContent() { } public static SubscriptionRenewedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static SubscriptionRenewedEvent fromJson(JsonObject jsonObj) { SubscriptionRenewedEvent obj = new SubscriptionRenewedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -162,32 +167,35 @@ public List getUnbilledCharges() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __subscriptionJson = JsonUtil.getObject(json, "subscription"); - if (__subscriptionJson != null) { - obj.subscription = Subscription.fromJson(__subscriptionJson); + JsonObject __subscriptionObj = JsonUtil.getJsonObject(jsonObj, "subscription"); + if (__subscriptionObj != null) { + obj.subscription = Subscription.fromJson(__subscriptionObj); } - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - obj.customer = Customer.fromJson(__customerJson); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + obj.customer = Customer.fromJson(__customerObj); } - String __cardJson = JsonUtil.getObject(json, "card"); - if (__cardJson != null) { - obj.card = Card.fromJson(__cardJson); + JsonObject __cardObj = JsonUtil.getJsonObject(jsonObj, "card"); + if (__cardObj != null) { + obj.card = Card.fromJson(__cardObj); } - String __invoiceJson = JsonUtil.getObject(json, "invoice"); - if (__invoiceJson != null) { - obj.invoice = Invoice.fromJson(__invoiceJson); + JsonObject __invoiceObj = JsonUtil.getJsonObject(jsonObj, "invoice"); + if (__invoiceObj != null) { + obj.invoice = Invoice.fromJson(__invoiceObj); } obj.unbilledCharges = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "unbilled_charges")).stream() - .map(UnbilledCharge::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "unbilled_charges"), UnbilledCharge::fromJson); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/event/SubscriptionResumedEvent.java b/src/main/java/com/chargebee/v4/models/event/SubscriptionResumedEvent.java index ccd57047..6ac66bc1 100644 --- a/src/main/java/com/chargebee/v4/models/event/SubscriptionResumedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/SubscriptionResumedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import java.util.List; import com.chargebee.v4.models.customer.Customer; @@ -64,25 +65,29 @@ public Content getContent() { } public static SubscriptionResumedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static SubscriptionResumedEvent fromJson(JsonObject jsonObj) { SubscriptionResumedEvent obj = new SubscriptionResumedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -162,32 +167,35 @@ public List getUnbilledCharges() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __subscriptionJson = JsonUtil.getObject(json, "subscription"); - if (__subscriptionJson != null) { - obj.subscription = Subscription.fromJson(__subscriptionJson); + JsonObject __subscriptionObj = JsonUtil.getJsonObject(jsonObj, "subscription"); + if (__subscriptionObj != null) { + obj.subscription = Subscription.fromJson(__subscriptionObj); } - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - obj.customer = Customer.fromJson(__customerJson); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + obj.customer = Customer.fromJson(__customerObj); } - String __cardJson = JsonUtil.getObject(json, "card"); - if (__cardJson != null) { - obj.card = Card.fromJson(__cardJson); + JsonObject __cardObj = JsonUtil.getJsonObject(jsonObj, "card"); + if (__cardObj != null) { + obj.card = Card.fromJson(__cardObj); } - String __invoiceJson = JsonUtil.getObject(json, "invoice"); - if (__invoiceJson != null) { - obj.invoice = Invoice.fromJson(__invoiceJson); + JsonObject __invoiceObj = JsonUtil.getJsonObject(jsonObj, "invoice"); + if (__invoiceObj != null) { + obj.invoice = Invoice.fromJson(__invoiceObj); } obj.unbilledCharges = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "unbilled_charges")).stream() - .map(UnbilledCharge::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "unbilled_charges"), UnbilledCharge::fromJson); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/event/SubscriptionResumptionScheduledEvent.java b/src/main/java/com/chargebee/v4/models/event/SubscriptionResumptionScheduledEvent.java index 5eea77b5..db43400c 100644 --- a/src/main/java/com/chargebee/v4/models/event/SubscriptionResumptionScheduledEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/SubscriptionResumptionScheduledEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.customer.Customer; @@ -61,25 +62,29 @@ public Content getContent() { } public static SubscriptionResumptionScheduledEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static SubscriptionResumptionScheduledEvent fromJson(JsonObject jsonObj) { SubscriptionResumptionScheduledEvent obj = new SubscriptionResumptionScheduledEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -154,26 +159,31 @@ public AdvanceInvoiceSchedule getAdvanceInvoiceSchedule() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __subscriptionJson = JsonUtil.getObject(json, "subscription"); - if (__subscriptionJson != null) { - obj.subscription = Subscription.fromJson(__subscriptionJson); + JsonObject __subscriptionObj = JsonUtil.getJsonObject(jsonObj, "subscription"); + if (__subscriptionObj != null) { + obj.subscription = Subscription.fromJson(__subscriptionObj); } - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - obj.customer = Customer.fromJson(__customerJson); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + obj.customer = Customer.fromJson(__customerObj); } - String __cardJson = JsonUtil.getObject(json, "card"); - if (__cardJson != null) { - obj.card = Card.fromJson(__cardJson); + JsonObject __cardObj = JsonUtil.getJsonObject(jsonObj, "card"); + if (__cardObj != null) { + obj.card = Card.fromJson(__cardObj); } - String __advanceInvoiceScheduleJson = JsonUtil.getObject(json, "advance_invoice_schedule"); - if (__advanceInvoiceScheduleJson != null) { - obj.advanceInvoiceSchedule = AdvanceInvoiceSchedule.fromJson(__advanceInvoiceScheduleJson); + JsonObject __advanceInvoiceScheduleObj = + JsonUtil.getJsonObject(jsonObj, "advance_invoice_schedule"); + if (__advanceInvoiceScheduleObj != null) { + obj.advanceInvoiceSchedule = AdvanceInvoiceSchedule.fromJson(__advanceInvoiceScheduleObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/SubscriptionScheduledCancellationRemovedEvent.java b/src/main/java/com/chargebee/v4/models/event/SubscriptionScheduledCancellationRemovedEvent.java index 1da3578d..94f908a5 100644 --- a/src/main/java/com/chargebee/v4/models/event/SubscriptionScheduledCancellationRemovedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/SubscriptionScheduledCancellationRemovedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.customer.Customer; @@ -61,26 +62,30 @@ public Content getContent() { } public static SubscriptionScheduledCancellationRemovedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static SubscriptionScheduledCancellationRemovedEvent fromJson(JsonObject jsonObj) { SubscriptionScheduledCancellationRemovedEvent obj = new SubscriptionScheduledCancellationRemovedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -156,26 +161,31 @@ public AdvanceInvoiceSchedule getAdvanceInvoiceSchedule() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __subscriptionJson = JsonUtil.getObject(json, "subscription"); - if (__subscriptionJson != null) { - obj.subscription = Subscription.fromJson(__subscriptionJson); + JsonObject __subscriptionObj = JsonUtil.getJsonObject(jsonObj, "subscription"); + if (__subscriptionObj != null) { + obj.subscription = Subscription.fromJson(__subscriptionObj); } - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - obj.customer = Customer.fromJson(__customerJson); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + obj.customer = Customer.fromJson(__customerObj); } - String __cardJson = JsonUtil.getObject(json, "card"); - if (__cardJson != null) { - obj.card = Card.fromJson(__cardJson); + JsonObject __cardObj = JsonUtil.getJsonObject(jsonObj, "card"); + if (__cardObj != null) { + obj.card = Card.fromJson(__cardObj); } - String __advanceInvoiceScheduleJson = JsonUtil.getObject(json, "advance_invoice_schedule"); - if (__advanceInvoiceScheduleJson != null) { - obj.advanceInvoiceSchedule = AdvanceInvoiceSchedule.fromJson(__advanceInvoiceScheduleJson); + JsonObject __advanceInvoiceScheduleObj = + JsonUtil.getJsonObject(jsonObj, "advance_invoice_schedule"); + if (__advanceInvoiceScheduleObj != null) { + obj.advanceInvoiceSchedule = AdvanceInvoiceSchedule.fromJson(__advanceInvoiceScheduleObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/SubscriptionScheduledChangesRemovedEvent.java b/src/main/java/com/chargebee/v4/models/event/SubscriptionScheduledChangesRemovedEvent.java index e14b1b54..3d823124 100644 --- a/src/main/java/com/chargebee/v4/models/event/SubscriptionScheduledChangesRemovedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/SubscriptionScheduledChangesRemovedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.customer.Customer; @@ -61,25 +62,29 @@ public Content getContent() { } public static SubscriptionScheduledChangesRemovedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static SubscriptionScheduledChangesRemovedEvent fromJson(JsonObject jsonObj) { SubscriptionScheduledChangesRemovedEvent obj = new SubscriptionScheduledChangesRemovedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -154,26 +159,31 @@ public AdvanceInvoiceSchedule getAdvanceInvoiceSchedule() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __subscriptionJson = JsonUtil.getObject(json, "subscription"); - if (__subscriptionJson != null) { - obj.subscription = Subscription.fromJson(__subscriptionJson); + JsonObject __subscriptionObj = JsonUtil.getJsonObject(jsonObj, "subscription"); + if (__subscriptionObj != null) { + obj.subscription = Subscription.fromJson(__subscriptionObj); } - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - obj.customer = Customer.fromJson(__customerJson); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + obj.customer = Customer.fromJson(__customerObj); } - String __cardJson = JsonUtil.getObject(json, "card"); - if (__cardJson != null) { - obj.card = Card.fromJson(__cardJson); + JsonObject __cardObj = JsonUtil.getJsonObject(jsonObj, "card"); + if (__cardObj != null) { + obj.card = Card.fromJson(__cardObj); } - String __advanceInvoiceScheduleJson = JsonUtil.getObject(json, "advance_invoice_schedule"); - if (__advanceInvoiceScheduleJson != null) { - obj.advanceInvoiceSchedule = AdvanceInvoiceSchedule.fromJson(__advanceInvoiceScheduleJson); + JsonObject __advanceInvoiceScheduleObj = + JsonUtil.getJsonObject(jsonObj, "advance_invoice_schedule"); + if (__advanceInvoiceScheduleObj != null) { + obj.advanceInvoiceSchedule = AdvanceInvoiceSchedule.fromJson(__advanceInvoiceScheduleObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/SubscriptionScheduledPauseRemovedEvent.java b/src/main/java/com/chargebee/v4/models/event/SubscriptionScheduledPauseRemovedEvent.java index f4eea215..e18663c6 100644 --- a/src/main/java/com/chargebee/v4/models/event/SubscriptionScheduledPauseRemovedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/SubscriptionScheduledPauseRemovedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.customer.Customer; @@ -61,25 +62,29 @@ public Content getContent() { } public static SubscriptionScheduledPauseRemovedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static SubscriptionScheduledPauseRemovedEvent fromJson(JsonObject jsonObj) { SubscriptionScheduledPauseRemovedEvent obj = new SubscriptionScheduledPauseRemovedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -154,26 +159,31 @@ public AdvanceInvoiceSchedule getAdvanceInvoiceSchedule() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __subscriptionJson = JsonUtil.getObject(json, "subscription"); - if (__subscriptionJson != null) { - obj.subscription = Subscription.fromJson(__subscriptionJson); + JsonObject __subscriptionObj = JsonUtil.getJsonObject(jsonObj, "subscription"); + if (__subscriptionObj != null) { + obj.subscription = Subscription.fromJson(__subscriptionObj); } - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - obj.customer = Customer.fromJson(__customerJson); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + obj.customer = Customer.fromJson(__customerObj); } - String __cardJson = JsonUtil.getObject(json, "card"); - if (__cardJson != null) { - obj.card = Card.fromJson(__cardJson); + JsonObject __cardObj = JsonUtil.getJsonObject(jsonObj, "card"); + if (__cardObj != null) { + obj.card = Card.fromJson(__cardObj); } - String __advanceInvoiceScheduleJson = JsonUtil.getObject(json, "advance_invoice_schedule"); - if (__advanceInvoiceScheduleJson != null) { - obj.advanceInvoiceSchedule = AdvanceInvoiceSchedule.fromJson(__advanceInvoiceScheduleJson); + JsonObject __advanceInvoiceScheduleObj = + JsonUtil.getJsonObject(jsonObj, "advance_invoice_schedule"); + if (__advanceInvoiceScheduleObj != null) { + obj.advanceInvoiceSchedule = AdvanceInvoiceSchedule.fromJson(__advanceInvoiceScheduleObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/SubscriptionScheduledResumptionRemovedEvent.java b/src/main/java/com/chargebee/v4/models/event/SubscriptionScheduledResumptionRemovedEvent.java index 22da9e30..1885ff4b 100644 --- a/src/main/java/com/chargebee/v4/models/event/SubscriptionScheduledResumptionRemovedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/SubscriptionScheduledResumptionRemovedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.customer.Customer; @@ -61,26 +62,30 @@ public Content getContent() { } public static SubscriptionScheduledResumptionRemovedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static SubscriptionScheduledResumptionRemovedEvent fromJson(JsonObject jsonObj) { SubscriptionScheduledResumptionRemovedEvent obj = new SubscriptionScheduledResumptionRemovedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -156,26 +161,31 @@ public AdvanceInvoiceSchedule getAdvanceInvoiceSchedule() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __subscriptionJson = JsonUtil.getObject(json, "subscription"); - if (__subscriptionJson != null) { - obj.subscription = Subscription.fromJson(__subscriptionJson); + JsonObject __subscriptionObj = JsonUtil.getJsonObject(jsonObj, "subscription"); + if (__subscriptionObj != null) { + obj.subscription = Subscription.fromJson(__subscriptionObj); } - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - obj.customer = Customer.fromJson(__customerJson); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + obj.customer = Customer.fromJson(__customerObj); } - String __cardJson = JsonUtil.getObject(json, "card"); - if (__cardJson != null) { - obj.card = Card.fromJson(__cardJson); + JsonObject __cardObj = JsonUtil.getJsonObject(jsonObj, "card"); + if (__cardObj != null) { + obj.card = Card.fromJson(__cardObj); } - String __advanceInvoiceScheduleJson = JsonUtil.getObject(json, "advance_invoice_schedule"); - if (__advanceInvoiceScheduleJson != null) { - obj.advanceInvoiceSchedule = AdvanceInvoiceSchedule.fromJson(__advanceInvoiceScheduleJson); + JsonObject __advanceInvoiceScheduleObj = + JsonUtil.getJsonObject(jsonObj, "advance_invoice_schedule"); + if (__advanceInvoiceScheduleObj != null) { + obj.advanceInvoiceSchedule = AdvanceInvoiceSchedule.fromJson(__advanceInvoiceScheduleObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/SubscriptionShippingAddressUpdatedEvent.java b/src/main/java/com/chargebee/v4/models/event/SubscriptionShippingAddressUpdatedEvent.java index 55118577..ffa32e27 100644 --- a/src/main/java/com/chargebee/v4/models/event/SubscriptionShippingAddressUpdatedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/SubscriptionShippingAddressUpdatedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.customer.Customer; @@ -61,25 +62,29 @@ public Content getContent() { } public static SubscriptionShippingAddressUpdatedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static SubscriptionShippingAddressUpdatedEvent fromJson(JsonObject jsonObj) { SubscriptionShippingAddressUpdatedEvent obj = new SubscriptionShippingAddressUpdatedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -154,26 +159,31 @@ public AdvanceInvoiceSchedule getAdvanceInvoiceSchedule() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __subscriptionJson = JsonUtil.getObject(json, "subscription"); - if (__subscriptionJson != null) { - obj.subscription = Subscription.fromJson(__subscriptionJson); + JsonObject __subscriptionObj = JsonUtil.getJsonObject(jsonObj, "subscription"); + if (__subscriptionObj != null) { + obj.subscription = Subscription.fromJson(__subscriptionObj); } - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - obj.customer = Customer.fromJson(__customerJson); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + obj.customer = Customer.fromJson(__customerObj); } - String __cardJson = JsonUtil.getObject(json, "card"); - if (__cardJson != null) { - obj.card = Card.fromJson(__cardJson); + JsonObject __cardObj = JsonUtil.getJsonObject(jsonObj, "card"); + if (__cardObj != null) { + obj.card = Card.fromJson(__cardObj); } - String __advanceInvoiceScheduleJson = JsonUtil.getObject(json, "advance_invoice_schedule"); - if (__advanceInvoiceScheduleJson != null) { - obj.advanceInvoiceSchedule = AdvanceInvoiceSchedule.fromJson(__advanceInvoiceScheduleJson); + JsonObject __advanceInvoiceScheduleObj = + JsonUtil.getJsonObject(jsonObj, "advance_invoice_schedule"); + if (__advanceInvoiceScheduleObj != null) { + obj.advanceInvoiceSchedule = AdvanceInvoiceSchedule.fromJson(__advanceInvoiceScheduleObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/SubscriptionStartedEvent.java b/src/main/java/com/chargebee/v4/models/event/SubscriptionStartedEvent.java index 136fd63e..82b2b777 100644 --- a/src/main/java/com/chargebee/v4/models/event/SubscriptionStartedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/SubscriptionStartedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.customer.Customer; @@ -61,25 +62,29 @@ public Content getContent() { } public static SubscriptionStartedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static SubscriptionStartedEvent fromJson(JsonObject jsonObj) { SubscriptionStartedEvent obj = new SubscriptionStartedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -154,26 +159,30 @@ public Invoice getInvoice() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __subscriptionJson = JsonUtil.getObject(json, "subscription"); - if (__subscriptionJson != null) { - obj.subscription = Subscription.fromJson(__subscriptionJson); + JsonObject __subscriptionObj = JsonUtil.getJsonObject(jsonObj, "subscription"); + if (__subscriptionObj != null) { + obj.subscription = Subscription.fromJson(__subscriptionObj); } - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - obj.customer = Customer.fromJson(__customerJson); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + obj.customer = Customer.fromJson(__customerObj); } - String __cardJson = JsonUtil.getObject(json, "card"); - if (__cardJson != null) { - obj.card = Card.fromJson(__cardJson); + JsonObject __cardObj = JsonUtil.getJsonObject(jsonObj, "card"); + if (__cardObj != null) { + obj.card = Card.fromJson(__cardObj); } - String __invoiceJson = JsonUtil.getObject(json, "invoice"); - if (__invoiceJson != null) { - obj.invoice = Invoice.fromJson(__invoiceJson); + JsonObject __invoiceObj = JsonUtil.getJsonObject(jsonObj, "invoice"); + if (__invoiceObj != null) { + obj.invoice = Invoice.fromJson(__invoiceObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/SubscriptionTrialEndReminderEvent.java b/src/main/java/com/chargebee/v4/models/event/SubscriptionTrialEndReminderEvent.java index f3588e1b..ef795649 100644 --- a/src/main/java/com/chargebee/v4/models/event/SubscriptionTrialEndReminderEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/SubscriptionTrialEndReminderEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.customer.Customer; @@ -61,25 +62,29 @@ public Content getContent() { } public static SubscriptionTrialEndReminderEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static SubscriptionTrialEndReminderEvent fromJson(JsonObject jsonObj) { SubscriptionTrialEndReminderEvent obj = new SubscriptionTrialEndReminderEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -154,26 +159,31 @@ public AdvanceInvoiceSchedule getAdvanceInvoiceSchedule() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __subscriptionJson = JsonUtil.getObject(json, "subscription"); - if (__subscriptionJson != null) { - obj.subscription = Subscription.fromJson(__subscriptionJson); + JsonObject __subscriptionObj = JsonUtil.getJsonObject(jsonObj, "subscription"); + if (__subscriptionObj != null) { + obj.subscription = Subscription.fromJson(__subscriptionObj); } - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - obj.customer = Customer.fromJson(__customerJson); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + obj.customer = Customer.fromJson(__customerObj); } - String __cardJson = JsonUtil.getObject(json, "card"); - if (__cardJson != null) { - obj.card = Card.fromJson(__cardJson); + JsonObject __cardObj = JsonUtil.getJsonObject(jsonObj, "card"); + if (__cardObj != null) { + obj.card = Card.fromJson(__cardObj); } - String __advanceInvoiceScheduleJson = JsonUtil.getObject(json, "advance_invoice_schedule"); - if (__advanceInvoiceScheduleJson != null) { - obj.advanceInvoiceSchedule = AdvanceInvoiceSchedule.fromJson(__advanceInvoiceScheduleJson); + JsonObject __advanceInvoiceScheduleObj = + JsonUtil.getJsonObject(jsonObj, "advance_invoice_schedule"); + if (__advanceInvoiceScheduleObj != null) { + obj.advanceInvoiceSchedule = AdvanceInvoiceSchedule.fromJson(__advanceInvoiceScheduleObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/SubscriptionTrialExtendedEvent.java b/src/main/java/com/chargebee/v4/models/event/SubscriptionTrialExtendedEvent.java index 84410e06..c7d60f72 100644 --- a/src/main/java/com/chargebee/v4/models/event/SubscriptionTrialExtendedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/SubscriptionTrialExtendedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.customer.Customer; @@ -61,25 +62,29 @@ public Content getContent() { } public static SubscriptionTrialExtendedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static SubscriptionTrialExtendedEvent fromJson(JsonObject jsonObj) { SubscriptionTrialExtendedEvent obj = new SubscriptionTrialExtendedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -154,26 +159,31 @@ public AdvanceInvoiceSchedule getAdvanceInvoiceSchedule() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __subscriptionJson = JsonUtil.getObject(json, "subscription"); - if (__subscriptionJson != null) { - obj.subscription = Subscription.fromJson(__subscriptionJson); + JsonObject __subscriptionObj = JsonUtil.getJsonObject(jsonObj, "subscription"); + if (__subscriptionObj != null) { + obj.subscription = Subscription.fromJson(__subscriptionObj); } - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - obj.customer = Customer.fromJson(__customerJson); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + obj.customer = Customer.fromJson(__customerObj); } - String __cardJson = JsonUtil.getObject(json, "card"); - if (__cardJson != null) { - obj.card = Card.fromJson(__cardJson); + JsonObject __cardObj = JsonUtil.getJsonObject(jsonObj, "card"); + if (__cardObj != null) { + obj.card = Card.fromJson(__cardObj); } - String __advanceInvoiceScheduleJson = JsonUtil.getObject(json, "advance_invoice_schedule"); - if (__advanceInvoiceScheduleJson != null) { - obj.advanceInvoiceSchedule = AdvanceInvoiceSchedule.fromJson(__advanceInvoiceScheduleJson); + JsonObject __advanceInvoiceScheduleObj = + JsonUtil.getJsonObject(jsonObj, "advance_invoice_schedule"); + if (__advanceInvoiceScheduleObj != null) { + obj.advanceInvoiceSchedule = AdvanceInvoiceSchedule.fromJson(__advanceInvoiceScheduleObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/TaxWithheldDeletedEvent.java b/src/main/java/com/chargebee/v4/models/event/TaxWithheldDeletedEvent.java index d573e7cd..a3f157e6 100644 --- a/src/main/java/com/chargebee/v4/models/event/TaxWithheldDeletedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/TaxWithheldDeletedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.taxWithheld.TaxWithheld; @@ -59,25 +60,29 @@ public Content getContent() { } public static TaxWithheldDeletedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static TaxWithheldDeletedEvent fromJson(JsonObject jsonObj) { TaxWithheldDeletedEvent obj = new TaxWithheldDeletedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -147,21 +152,25 @@ public CreditNote getCreditNote() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __taxWithheldJson = JsonUtil.getObject(json, "tax_withheld"); - if (__taxWithheldJson != null) { - obj.taxWithheld = TaxWithheld.fromJson(__taxWithheldJson); + JsonObject __taxWithheldObj = JsonUtil.getJsonObject(jsonObj, "tax_withheld"); + if (__taxWithheldObj != null) { + obj.taxWithheld = TaxWithheld.fromJson(__taxWithheldObj); } - String __invoiceJson = JsonUtil.getObject(json, "invoice"); - if (__invoiceJson != null) { - obj.invoice = Invoice.fromJson(__invoiceJson); + JsonObject __invoiceObj = JsonUtil.getJsonObject(jsonObj, "invoice"); + if (__invoiceObj != null) { + obj.invoice = Invoice.fromJson(__invoiceObj); } - String __creditNoteJson = JsonUtil.getObject(json, "credit_note"); - if (__creditNoteJson != null) { - obj.creditNote = CreditNote.fromJson(__creditNoteJson); + JsonObject __creditNoteObj = JsonUtil.getJsonObject(jsonObj, "credit_note"); + if (__creditNoteObj != null) { + obj.creditNote = CreditNote.fromJson(__creditNoteObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/TaxWithheldRecordedEvent.java b/src/main/java/com/chargebee/v4/models/event/TaxWithheldRecordedEvent.java index 3634e03c..967666a5 100644 --- a/src/main/java/com/chargebee/v4/models/event/TaxWithheldRecordedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/TaxWithheldRecordedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.taxWithheld.TaxWithheld; @@ -59,25 +60,29 @@ public Content getContent() { } public static TaxWithheldRecordedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static TaxWithheldRecordedEvent fromJson(JsonObject jsonObj) { TaxWithheldRecordedEvent obj = new TaxWithheldRecordedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -147,21 +152,25 @@ public CreditNote getCreditNote() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __taxWithheldJson = JsonUtil.getObject(json, "tax_withheld"); - if (__taxWithheldJson != null) { - obj.taxWithheld = TaxWithheld.fromJson(__taxWithheldJson); + JsonObject __taxWithheldObj = JsonUtil.getJsonObject(jsonObj, "tax_withheld"); + if (__taxWithheldObj != null) { + obj.taxWithheld = TaxWithheld.fromJson(__taxWithheldObj); } - String __invoiceJson = JsonUtil.getObject(json, "invoice"); - if (__invoiceJson != null) { - obj.invoice = Invoice.fromJson(__invoiceJson); + JsonObject __invoiceObj = JsonUtil.getJsonObject(jsonObj, "invoice"); + if (__invoiceObj != null) { + obj.invoice = Invoice.fromJson(__invoiceObj); } - String __creditNoteJson = JsonUtil.getObject(json, "credit_note"); - if (__creditNoteJson != null) { - obj.creditNote = CreditNote.fromJson(__creditNoteJson); + JsonObject __creditNoteObj = JsonUtil.getJsonObject(jsonObj, "credit_note"); + if (__creditNoteObj != null) { + obj.creditNote = CreditNote.fromJson(__creditNoteObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/TaxWithheldRefundedEvent.java b/src/main/java/com/chargebee/v4/models/event/TaxWithheldRefundedEvent.java index 813fcfeb..c02f4bbc 100644 --- a/src/main/java/com/chargebee/v4/models/event/TaxWithheldRefundedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/TaxWithheldRefundedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.taxWithheld.TaxWithheld; @@ -59,25 +60,29 @@ public Content getContent() { } public static TaxWithheldRefundedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static TaxWithheldRefundedEvent fromJson(JsonObject jsonObj) { TaxWithheldRefundedEvent obj = new TaxWithheldRefundedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -147,21 +152,25 @@ public CreditNote getCreditNote() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __taxWithheldJson = JsonUtil.getObject(json, "tax_withheld"); - if (__taxWithheldJson != null) { - obj.taxWithheld = TaxWithheld.fromJson(__taxWithheldJson); + JsonObject __taxWithheldObj = JsonUtil.getJsonObject(jsonObj, "tax_withheld"); + if (__taxWithheldObj != null) { + obj.taxWithheld = TaxWithheld.fromJson(__taxWithheldObj); } - String __invoiceJson = JsonUtil.getObject(json, "invoice"); - if (__invoiceJson != null) { - obj.invoice = Invoice.fromJson(__invoiceJson); + JsonObject __invoiceObj = JsonUtil.getJsonObject(jsonObj, "invoice"); + if (__invoiceObj != null) { + obj.invoice = Invoice.fromJson(__invoiceObj); } - String __creditNoteJson = JsonUtil.getObject(json, "credit_note"); - if (__creditNoteJson != null) { - obj.creditNote = CreditNote.fromJson(__creditNoteJson); + JsonObject __creditNoteObj = JsonUtil.getJsonObject(jsonObj, "credit_note"); + if (__creditNoteObj != null) { + obj.creditNote = CreditNote.fromJson(__creditNoteObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/TokenConsumedEvent.java b/src/main/java/com/chargebee/v4/models/event/TokenConsumedEvent.java index 19756886..edd21f29 100644 --- a/src/main/java/com/chargebee/v4/models/event/TokenConsumedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/TokenConsumedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.token.Token; @@ -55,25 +56,29 @@ public Content getContent() { } public static TokenConsumedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static TokenConsumedEvent fromJson(JsonObject jsonObj) { TokenConsumedEvent obj = new TokenConsumedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -133,11 +138,15 @@ public Token getToken() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __tokenJson = JsonUtil.getObject(json, "token"); - if (__tokenJson != null) { - obj.token = Token.fromJson(__tokenJson); + JsonObject __tokenObj = JsonUtil.getJsonObject(jsonObj, "token"); + if (__tokenObj != null) { + obj.token = Token.fromJson(__tokenObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/TokenCreatedEvent.java b/src/main/java/com/chargebee/v4/models/event/TokenCreatedEvent.java index 9dbacd7f..b867ad37 100644 --- a/src/main/java/com/chargebee/v4/models/event/TokenCreatedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/TokenCreatedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.token.Token; @@ -55,25 +56,29 @@ public Content getContent() { } public static TokenCreatedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static TokenCreatedEvent fromJson(JsonObject jsonObj) { TokenCreatedEvent obj = new TokenCreatedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -133,11 +138,15 @@ public Token getToken() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __tokenJson = JsonUtil.getObject(json, "token"); - if (__tokenJson != null) { - obj.token = Token.fromJson(__tokenJson); + JsonObject __tokenObj = JsonUtil.getJsonObject(jsonObj, "token"); + if (__tokenObj != null) { + obj.token = Token.fromJson(__tokenObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/TokenExpiredEvent.java b/src/main/java/com/chargebee/v4/models/event/TokenExpiredEvent.java index 1625dd98..7d483ec6 100644 --- a/src/main/java/com/chargebee/v4/models/event/TokenExpiredEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/TokenExpiredEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.token.Token; @@ -55,25 +56,29 @@ public Content getContent() { } public static TokenExpiredEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static TokenExpiredEvent fromJson(JsonObject jsonObj) { TokenExpiredEvent obj = new TokenExpiredEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -133,11 +138,15 @@ public Token getToken() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __tokenJson = JsonUtil.getObject(json, "token"); - if (__tokenJson != null) { - obj.token = Token.fromJson(__tokenJson); + JsonObject __tokenObj = JsonUtil.getJsonObject(jsonObj, "token"); + if (__tokenObj != null) { + obj.token = Token.fromJson(__tokenObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/TransactionCreatedEvent.java b/src/main/java/com/chargebee/v4/models/event/TransactionCreatedEvent.java index ba1e05b9..44334b0b 100644 --- a/src/main/java/com/chargebee/v4/models/event/TransactionCreatedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/TransactionCreatedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.transaction.Transaction; @@ -55,25 +56,29 @@ public Content getContent() { } public static TransactionCreatedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static TransactionCreatedEvent fromJson(JsonObject jsonObj) { TransactionCreatedEvent obj = new TransactionCreatedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -133,11 +138,15 @@ public Transaction getTransaction() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __transactionJson = JsonUtil.getObject(json, "transaction"); - if (__transactionJson != null) { - obj.transaction = Transaction.fromJson(__transactionJson); + JsonObject __transactionObj = JsonUtil.getJsonObject(jsonObj, "transaction"); + if (__transactionObj != null) { + obj.transaction = Transaction.fromJson(__transactionObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/TransactionDeletedEvent.java b/src/main/java/com/chargebee/v4/models/event/TransactionDeletedEvent.java index b4258f32..1a2a8a80 100644 --- a/src/main/java/com/chargebee/v4/models/event/TransactionDeletedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/TransactionDeletedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.transaction.Transaction; @@ -55,25 +56,29 @@ public Content getContent() { } public static TransactionDeletedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static TransactionDeletedEvent fromJson(JsonObject jsonObj) { TransactionDeletedEvent obj = new TransactionDeletedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -133,11 +138,15 @@ public Transaction getTransaction() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __transactionJson = JsonUtil.getObject(json, "transaction"); - if (__transactionJson != null) { - obj.transaction = Transaction.fromJson(__transactionJson); + JsonObject __transactionObj = JsonUtil.getJsonObject(jsonObj, "transaction"); + if (__transactionObj != null) { + obj.transaction = Transaction.fromJson(__transactionObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/TransactionUpdatedEvent.java b/src/main/java/com/chargebee/v4/models/event/TransactionUpdatedEvent.java index 6697b163..15421d64 100644 --- a/src/main/java/com/chargebee/v4/models/event/TransactionUpdatedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/TransactionUpdatedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.transaction.Transaction; @@ -55,25 +56,29 @@ public Content getContent() { } public static TransactionUpdatedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static TransactionUpdatedEvent fromJson(JsonObject jsonObj) { TransactionUpdatedEvent obj = new TransactionUpdatedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -133,11 +138,15 @@ public Transaction getTransaction() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __transactionJson = JsonUtil.getObject(json, "transaction"); - if (__transactionJson != null) { - obj.transaction = Transaction.fromJson(__transactionJson); + JsonObject __transactionObj = JsonUtil.getJsonObject(jsonObj, "transaction"); + if (__transactionObj != null) { + obj.transaction = Transaction.fromJson(__transactionObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/UnbilledChargesCreatedEvent.java b/src/main/java/com/chargebee/v4/models/event/UnbilledChargesCreatedEvent.java index cb815350..6fd1775e 100644 --- a/src/main/java/com/chargebee/v4/models/event/UnbilledChargesCreatedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/UnbilledChargesCreatedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import java.util.List; import com.chargebee.v4.models.unbilledCharge.UnbilledCharge; @@ -56,25 +57,29 @@ public Content getContent() { } public static UnbilledChargesCreatedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static UnbilledChargesCreatedEvent fromJson(JsonObject jsonObj) { UnbilledChargesCreatedEvent obj = new UnbilledChargesCreatedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -134,12 +139,15 @@ public List getUnbilledCharges() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); obj.unbilledCharges = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "unbilled_charges")).stream() - .map(UnbilledCharge::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "unbilled_charges"), UnbilledCharge::fromJson); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/event/UnbilledChargesDeletedEvent.java b/src/main/java/com/chargebee/v4/models/event/UnbilledChargesDeletedEvent.java index d40144e8..2ad3ed96 100644 --- a/src/main/java/com/chargebee/v4/models/event/UnbilledChargesDeletedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/UnbilledChargesDeletedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import java.util.List; import com.chargebee.v4.models.unbilledCharge.UnbilledCharge; @@ -56,25 +57,29 @@ public Content getContent() { } public static UnbilledChargesDeletedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static UnbilledChargesDeletedEvent fromJson(JsonObject jsonObj) { UnbilledChargesDeletedEvent obj = new UnbilledChargesDeletedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -134,12 +139,15 @@ public List getUnbilledCharges() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); obj.unbilledCharges = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "unbilled_charges")).stream() - .map(UnbilledCharge::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "unbilled_charges"), UnbilledCharge::fromJson); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/event/UnbilledChargesInvoicedEvent.java b/src/main/java/com/chargebee/v4/models/event/UnbilledChargesInvoicedEvent.java index b60005e9..cc505333 100644 --- a/src/main/java/com/chargebee/v4/models/event/UnbilledChargesInvoicedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/UnbilledChargesInvoicedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import java.util.List; import com.chargebee.v4.models.unbilledCharge.UnbilledCharge; @@ -58,25 +59,29 @@ public Content getContent() { } public static UnbilledChargesInvoicedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static UnbilledChargesInvoicedEvent fromJson(JsonObject jsonObj) { UnbilledChargesInvoicedEvent obj = new UnbilledChargesInvoicedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -141,16 +146,19 @@ public Invoice getInvoice() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); obj.unbilledCharges = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "unbilled_charges")).stream() - .map(UnbilledCharge::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "unbilled_charges"), UnbilledCharge::fromJson); - String __invoiceJson = JsonUtil.getObject(json, "invoice"); - if (__invoiceJson != null) { - obj.invoice = Invoice.fromJson(__invoiceJson); + JsonObject __invoiceObj = JsonUtil.getJsonObject(jsonObj, "invoice"); + if (__invoiceObj != null) { + obj.invoice = Invoice.fromJson(__invoiceObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/UnbilledChargesVoidedEvent.java b/src/main/java/com/chargebee/v4/models/event/UnbilledChargesVoidedEvent.java index 452b735b..aa5786b4 100644 --- a/src/main/java/com/chargebee/v4/models/event/UnbilledChargesVoidedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/UnbilledChargesVoidedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import java.util.List; import com.chargebee.v4.models.unbilledCharge.UnbilledCharge; @@ -56,25 +57,29 @@ public Content getContent() { } public static UnbilledChargesVoidedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static UnbilledChargesVoidedEvent fromJson(JsonObject jsonObj) { UnbilledChargesVoidedEvent obj = new UnbilledChargesVoidedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -134,12 +139,15 @@ public List getUnbilledCharges() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); obj.unbilledCharges = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "unbilled_charges")).stream() - .map(UnbilledCharge::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "unbilled_charges"), UnbilledCharge::fromJson); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/event/UsageFileIngestedEvent.java b/src/main/java/com/chargebee/v4/models/event/UsageFileIngestedEvent.java index ea208150..5e4fa706 100644 --- a/src/main/java/com/chargebee/v4/models/event/UsageFileIngestedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/UsageFileIngestedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.usageFile.UsageFile; @@ -55,25 +56,29 @@ public Content getContent() { } public static UsageFileIngestedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static UsageFileIngestedEvent fromJson(JsonObject jsonObj) { UsageFileIngestedEvent obj = new UsageFileIngestedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -133,11 +138,15 @@ public UsageFile getUsageFile() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __usageFileJson = JsonUtil.getObject(json, "usage_file"); - if (__usageFileJson != null) { - obj.usageFile = UsageFile.fromJson(__usageFileJson); + JsonObject __usageFileObj = JsonUtil.getJsonObject(jsonObj, "usage_file"); + if (__usageFileObj != null) { + obj.usageFile = UsageFile.fromJson(__usageFileObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/VariantCreatedEvent.java b/src/main/java/com/chargebee/v4/models/event/VariantCreatedEvent.java index 1cce8de3..d7724ed5 100644 --- a/src/main/java/com/chargebee/v4/models/event/VariantCreatedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/VariantCreatedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.variant.Variant; @@ -55,25 +56,29 @@ public Content getContent() { } public static VariantCreatedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static VariantCreatedEvent fromJson(JsonObject jsonObj) { VariantCreatedEvent obj = new VariantCreatedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -133,11 +138,15 @@ public Variant getVariant() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __variantJson = JsonUtil.getObject(json, "variant"); - if (__variantJson != null) { - obj.variant = Variant.fromJson(__variantJson); + JsonObject __variantObj = JsonUtil.getJsonObject(jsonObj, "variant"); + if (__variantObj != null) { + obj.variant = Variant.fromJson(__variantObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/VariantDeletedEvent.java b/src/main/java/com/chargebee/v4/models/event/VariantDeletedEvent.java index 769fe7e1..caf2a7ed 100644 --- a/src/main/java/com/chargebee/v4/models/event/VariantDeletedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/VariantDeletedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.variant.Variant; @@ -55,25 +56,29 @@ public Content getContent() { } public static VariantDeletedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static VariantDeletedEvent fromJson(JsonObject jsonObj) { VariantDeletedEvent obj = new VariantDeletedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -133,11 +138,15 @@ public Variant getVariant() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __variantJson = JsonUtil.getObject(json, "variant"); - if (__variantJson != null) { - obj.variant = Variant.fromJson(__variantJson); + JsonObject __variantObj = JsonUtil.getJsonObject(jsonObj, "variant"); + if (__variantObj != null) { + obj.variant = Variant.fromJson(__variantObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/VariantUpdatedEvent.java b/src/main/java/com/chargebee/v4/models/event/VariantUpdatedEvent.java index 52f26a62..b36270ae 100644 --- a/src/main/java/com/chargebee/v4/models/event/VariantUpdatedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/VariantUpdatedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.variant.Variant; @@ -55,25 +56,29 @@ public Content getContent() { } public static VariantUpdatedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static VariantUpdatedEvent fromJson(JsonObject jsonObj) { VariantUpdatedEvent obj = new VariantUpdatedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -133,11 +138,15 @@ public Variant getVariant() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __variantJson = JsonUtil.getObject(json, "variant"); - if (__variantJson != null) { - obj.variant = Variant.fromJson(__variantJson); + JsonObject __variantObj = JsonUtil.getJsonObject(jsonObj, "variant"); + if (__variantObj != null) { + obj.variant = Variant.fromJson(__variantObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/VirtualBankAccountAddedEvent.java b/src/main/java/com/chargebee/v4/models/event/VirtualBankAccountAddedEvent.java index fd49f629..87e0579c 100644 --- a/src/main/java/com/chargebee/v4/models/event/VirtualBankAccountAddedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/VirtualBankAccountAddedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.customer.Customer; @@ -57,25 +58,29 @@ public Content getContent() { } public static VirtualBankAccountAddedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static VirtualBankAccountAddedEvent fromJson(JsonObject jsonObj) { VirtualBankAccountAddedEvent obj = new VirtualBankAccountAddedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -140,16 +145,20 @@ public VirtualBankAccount getVirtualBankAccount() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - obj.customer = Customer.fromJson(__customerJson); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + obj.customer = Customer.fromJson(__customerObj); } - String __virtualBankAccountJson = JsonUtil.getObject(json, "virtual_bank_account"); - if (__virtualBankAccountJson != null) { - obj.virtualBankAccount = VirtualBankAccount.fromJson(__virtualBankAccountJson); + JsonObject __virtualBankAccountObj = JsonUtil.getJsonObject(jsonObj, "virtual_bank_account"); + if (__virtualBankAccountObj != null) { + obj.virtualBankAccount = VirtualBankAccount.fromJson(__virtualBankAccountObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/VirtualBankAccountDeletedEvent.java b/src/main/java/com/chargebee/v4/models/event/VirtualBankAccountDeletedEvent.java index 4b9ae5c9..5d17e1b7 100644 --- a/src/main/java/com/chargebee/v4/models/event/VirtualBankAccountDeletedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/VirtualBankAccountDeletedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.customer.Customer; @@ -57,25 +58,29 @@ public Content getContent() { } public static VirtualBankAccountDeletedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static VirtualBankAccountDeletedEvent fromJson(JsonObject jsonObj) { VirtualBankAccountDeletedEvent obj = new VirtualBankAccountDeletedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -140,16 +145,20 @@ public VirtualBankAccount getVirtualBankAccount() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - obj.customer = Customer.fromJson(__customerJson); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + obj.customer = Customer.fromJson(__customerObj); } - String __virtualBankAccountJson = JsonUtil.getObject(json, "virtual_bank_account"); - if (__virtualBankAccountJson != null) { - obj.virtualBankAccount = VirtualBankAccount.fromJson(__virtualBankAccountJson); + JsonObject __virtualBankAccountObj = JsonUtil.getJsonObject(jsonObj, "virtual_bank_account"); + if (__virtualBankAccountObj != null) { + obj.virtualBankAccount = VirtualBankAccount.fromJson(__virtualBankAccountObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/VirtualBankAccountUpdatedEvent.java b/src/main/java/com/chargebee/v4/models/event/VirtualBankAccountUpdatedEvent.java index ea796642..493ba95e 100644 --- a/src/main/java/com/chargebee/v4/models/event/VirtualBankAccountUpdatedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/VirtualBankAccountUpdatedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.customer.Customer; @@ -57,25 +58,29 @@ public Content getContent() { } public static VirtualBankAccountUpdatedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static VirtualBankAccountUpdatedEvent fromJson(JsonObject jsonObj) { VirtualBankAccountUpdatedEvent obj = new VirtualBankAccountUpdatedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -140,16 +145,20 @@ public VirtualBankAccount getVirtualBankAccount() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - obj.customer = Customer.fromJson(__customerJson); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + obj.customer = Customer.fromJson(__customerObj); } - String __virtualBankAccountJson = JsonUtil.getObject(json, "virtual_bank_account"); - if (__virtualBankAccountJson != null) { - obj.virtualBankAccount = VirtualBankAccount.fromJson(__virtualBankAccountJson); + JsonObject __virtualBankAccountObj = JsonUtil.getJsonObject(jsonObj, "virtual_bank_account"); + if (__virtualBankAccountObj != null) { + obj.virtualBankAccount = VirtualBankAccount.fromJson(__virtualBankAccountObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/VoucherCreateFailedEvent.java b/src/main/java/com/chargebee/v4/models/event/VoucherCreateFailedEvent.java index e6dcfcad..b2f4bc61 100644 --- a/src/main/java/com/chargebee/v4/models/event/VoucherCreateFailedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/VoucherCreateFailedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.paymentVoucher.PaymentVoucher; @@ -55,25 +56,29 @@ public Content getContent() { } public static VoucherCreateFailedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static VoucherCreateFailedEvent fromJson(JsonObject jsonObj) { VoucherCreateFailedEvent obj = new VoucherCreateFailedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -133,11 +138,15 @@ public PaymentVoucher getPaymentVoucher() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __paymentVoucherJson = JsonUtil.getObject(json, "payment_voucher"); - if (__paymentVoucherJson != null) { - obj.paymentVoucher = PaymentVoucher.fromJson(__paymentVoucherJson); + JsonObject __paymentVoucherObj = JsonUtil.getJsonObject(jsonObj, "payment_voucher"); + if (__paymentVoucherObj != null) { + obj.paymentVoucher = PaymentVoucher.fromJson(__paymentVoucherObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/VoucherCreatedEvent.java b/src/main/java/com/chargebee/v4/models/event/VoucherCreatedEvent.java index ef10c33c..42207e33 100644 --- a/src/main/java/com/chargebee/v4/models/event/VoucherCreatedEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/VoucherCreatedEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.paymentVoucher.PaymentVoucher; @@ -55,25 +56,29 @@ public Content getContent() { } public static VoucherCreatedEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static VoucherCreatedEvent fromJson(JsonObject jsonObj) { VoucherCreatedEvent obj = new VoucherCreatedEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -133,11 +138,15 @@ public PaymentVoucher getPaymentVoucher() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __paymentVoucherJson = JsonUtil.getObject(json, "payment_voucher"); - if (__paymentVoucherJson != null) { - obj.paymentVoucher = PaymentVoucher.fromJson(__paymentVoucherJson); + JsonObject __paymentVoucherObj = JsonUtil.getJsonObject(jsonObj, "payment_voucher"); + if (__paymentVoucherObj != null) { + obj.paymentVoucher = PaymentVoucher.fromJson(__paymentVoucherObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/VoucherExpiredEvent.java b/src/main/java/com/chargebee/v4/models/event/VoucherExpiredEvent.java index 6c2fc19a..373ae41b 100644 --- a/src/main/java/com/chargebee/v4/models/event/VoucherExpiredEvent.java +++ b/src/main/java/com/chargebee/v4/models/event/VoucherExpiredEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.event; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.models.paymentVoucher.PaymentVoucher; @@ -55,25 +56,29 @@ public Content getContent() { } public static VoucherExpiredEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static VoucherExpiredEvent fromJson(JsonObject jsonObj) { VoucherExpiredEvent obj = new VoucherExpiredEvent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.occurredAt = JsonUtil.getLong(json, "occurred_at"); + obj.occurredAt = JsonUtil.getLong(jsonObj, "occurred_at"); - obj.source = JsonUtil.getString(json, "source"); + obj.source = JsonUtil.getString(jsonObj, "source"); - obj.object = JsonUtil.getString(json, "object"); + obj.object = JsonUtil.getString(jsonObj, "object"); - obj.apiVersion = JsonUtil.getString(json, "api_version"); + obj.apiVersion = JsonUtil.getString(jsonObj, "api_version"); - obj.eventType = JsonUtil.getString(json, "event_type"); + obj.eventType = JsonUtil.getString(jsonObj, "event_type"); - obj.webhookStatus = JsonUtil.getString(json, "webhook_status"); + obj.webhookStatus = JsonUtil.getString(jsonObj, "webhook_status"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } return obj; @@ -133,11 +138,15 @@ public PaymentVoucher getPaymentVoucher() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - String __paymentVoucherJson = JsonUtil.getObject(json, "payment_voucher"); - if (__paymentVoucherJson != null) { - obj.paymentVoucher = PaymentVoucher.fromJson(__paymentVoucherJson); + JsonObject __paymentVoucherObj = JsonUtil.getJsonObject(jsonObj, "payment_voucher"); + if (__paymentVoucherObj != null) { + obj.paymentVoucher = PaymentVoucher.fromJson(__paymentVoucherObj); } return obj; diff --git a/src/main/java/com/chargebee/v4/models/event/responses/EventListResponse.java b/src/main/java/com/chargebee/v4/models/event/responses/EventListResponse.java index eb02bd9a..31ec1c6a 100644 --- a/src/main/java/com/chargebee/v4/models/event/responses/EventListResponse.java +++ b/src/main/java/com/chargebee/v4/models/event/responses/EventListResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.exceptions.ChargebeeException; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; import com.chargebee.v4.services.EventService; import com.chargebee.v4.models.event.params.EventListParams; @@ -43,13 +44,12 @@ private EventListResponse( */ public static EventListResponse fromJson(String json) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(EventListItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "list"), EventListItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new EventListResponse(list, nextOffset, null, null, null); } catch (Exception e) { @@ -64,13 +64,12 @@ public static EventListResponse fromJson(String json) { public static EventListResponse fromJson( String json, EventService service, EventListParams originalParams, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(EventListItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "list"), EventListItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new EventListResponse(list, nextOffset, service, originalParams, httpResponse); } catch (Exception e) { @@ -170,11 +169,15 @@ public Event getEvent() { } public static EventListItem fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static EventListItem fromJson(JsonObject jsonObj) { EventListItem item = new EventListItem(); - String __eventJson = JsonUtil.getObject(json, "event"); - if (__eventJson != null) { - item.event = Event.fromJson(__eventJson); + JsonObject __eventObj = JsonUtil.getJsonObject(jsonObj, "event"); + if (__eventObj != null) { + item.event = Event.fromJson(__eventObj); } return item; diff --git a/src/main/java/com/chargebee/v4/models/event/responses/EventRetrieveResponse.java b/src/main/java/com/chargebee/v4/models/event/responses/EventRetrieveResponse.java index 3b93eda9..d62fcc02 100644 --- a/src/main/java/com/chargebee/v4/models/event/responses/EventRetrieveResponse.java +++ b/src/main/java/com/chargebee/v4/models/event/responses/EventRetrieveResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static EventRetrieveResponse fromJson(String json) { /** Parse JSON response into EventRetrieveResponse object with HTTP response. */ public static EventRetrieveResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __eventJson = JsonUtil.getObject(json, "event"); - if (__eventJson != null) { - builder.event(Event.fromJson(__eventJson)); + JsonObject __eventObj = JsonUtil.getJsonObject(jsonObj, "event"); + if (__eventObj != null) { + builder.event(Event.fromJson(__eventObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/export/Export.java b/src/main/java/com/chargebee/v4/models/export/Export.java index 13b9fcf4..fa61df8d 100644 --- a/src/main/java/com/chargebee/v4/models/export/Export.java +++ b/src/main/java/com/chargebee/v4/models/export/Export.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.export; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import java.sql.Timestamp; public class Export { @@ -102,21 +103,25 @@ public static Status fromString(String value) { } public static Export fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Export fromJson(JsonObject jsonObj) { Export obj = new Export(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.operationType = JsonUtil.getString(json, "operation_type"); + obj.operationType = JsonUtil.getString(jsonObj, "operation_type"); - obj.mimeType = MimeType.fromString(JsonUtil.getString(json, "mime_type")); + obj.mimeType = MimeType.fromString(JsonUtil.getString(jsonObj, "mime_type")); - obj.status = Status.fromString(JsonUtil.getString(json, "status")); + obj.status = Status.fromString(JsonUtil.getString(jsonObj, "status")); - obj.createdAt = JsonUtil.getTimestamp(json, "created_at"); + obj.createdAt = JsonUtil.getTimestamp(jsonObj, "created_at"); - String __downloadJson = JsonUtil.getObject(json, "download"); - if (__downloadJson != null) { - obj.download = Download.fromJson(__downloadJson); + JsonObject __downloadObj = JsonUtil.getJsonObject(jsonObj, "download"); + if (__downloadObj != null) { + obj.download = Download.fromJson(__downloadObj); } return obj; @@ -179,13 +184,17 @@ public String getMimeType() { } public static Download fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Download fromJson(JsonObject jsonObj) { Download obj = new Download(); - obj.downloadUrl = JsonUtil.getString(json, "download_url"); + obj.downloadUrl = JsonUtil.getString(jsonObj, "download_url"); - obj.validTill = JsonUtil.getTimestamp(json, "valid_till"); + obj.validTill = JsonUtil.getTimestamp(jsonObj, "valid_till"); - obj.mimeType = JsonUtil.getString(json, "mime_type"); + obj.mimeType = JsonUtil.getString(jsonObj, "mime_type"); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/export/responses/ExportAddonsResponse.java b/src/main/java/com/chargebee/v4/models/export/responses/ExportAddonsResponse.java index 2d9efec5..0716b3cd 100644 --- a/src/main/java/com/chargebee/v4/models/export/responses/ExportAddonsResponse.java +++ b/src/main/java/com/chargebee/v4/models/export/responses/ExportAddonsResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -26,11 +27,12 @@ public static ExportAddonsResponse fromJson(String json) { /** Parse JSON response into ExportAddonsResponse object with HTTP response. */ public static ExportAddonsResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __exportJson = JsonUtil.getObject(json, "export"); - if (__exportJson != null) { - builder.export(Export.fromJson(__exportJson)); + JsonObject __exportObj = JsonUtil.getJsonObject(jsonObj, "export"); + if (__exportObj != null) { + builder.export(Export.fromJson(__exportObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/export/responses/ExportAttachedItemsResponse.java b/src/main/java/com/chargebee/v4/models/export/responses/ExportAttachedItemsResponse.java index 49879215..7ab690d5 100644 --- a/src/main/java/com/chargebee/v4/models/export/responses/ExportAttachedItemsResponse.java +++ b/src/main/java/com/chargebee/v4/models/export/responses/ExportAttachedItemsResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static ExportAttachedItemsResponse fromJson(String json) { /** Parse JSON response into ExportAttachedItemsResponse object with HTTP response. */ public static ExportAttachedItemsResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __exportJson = JsonUtil.getObject(json, "export"); - if (__exportJson != null) { - builder.export(Export.fromJson(__exportJson)); + JsonObject __exportObj = JsonUtil.getJsonObject(jsonObj, "export"); + if (__exportObj != null) { + builder.export(Export.fromJson(__exportObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/export/responses/ExportCouponsResponse.java b/src/main/java/com/chargebee/v4/models/export/responses/ExportCouponsResponse.java index eabc1c64..9eb981d2 100644 --- a/src/main/java/com/chargebee/v4/models/export/responses/ExportCouponsResponse.java +++ b/src/main/java/com/chargebee/v4/models/export/responses/ExportCouponsResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -26,11 +27,12 @@ public static ExportCouponsResponse fromJson(String json) { /** Parse JSON response into ExportCouponsResponse object with HTTP response. */ public static ExportCouponsResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __exportJson = JsonUtil.getObject(json, "export"); - if (__exportJson != null) { - builder.export(Export.fromJson(__exportJson)); + JsonObject __exportObj = JsonUtil.getJsonObject(jsonObj, "export"); + if (__exportObj != null) { + builder.export(Export.fromJson(__exportObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/export/responses/ExportCreditNotesResponse.java b/src/main/java/com/chargebee/v4/models/export/responses/ExportCreditNotesResponse.java index e68d3c00..e5b82ecc 100644 --- a/src/main/java/com/chargebee/v4/models/export/responses/ExportCreditNotesResponse.java +++ b/src/main/java/com/chargebee/v4/models/export/responses/ExportCreditNotesResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static ExportCreditNotesResponse fromJson(String json) { /** Parse JSON response into ExportCreditNotesResponse object with HTTP response. */ public static ExportCreditNotesResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __exportJson = JsonUtil.getObject(json, "export"); - if (__exportJson != null) { - builder.export(Export.fromJson(__exportJson)); + JsonObject __exportObj = JsonUtil.getJsonObject(jsonObj, "export"); + if (__exportObj != null) { + builder.export(Export.fromJson(__exportObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/export/responses/ExportCustomersResponse.java b/src/main/java/com/chargebee/v4/models/export/responses/ExportCustomersResponse.java index 3e86bb8c..64acebf1 100644 --- a/src/main/java/com/chargebee/v4/models/export/responses/ExportCustomersResponse.java +++ b/src/main/java/com/chargebee/v4/models/export/responses/ExportCustomersResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -26,11 +27,12 @@ public static ExportCustomersResponse fromJson(String json) { /** Parse JSON response into ExportCustomersResponse object with HTTP response. */ public static ExportCustomersResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __exportJson = JsonUtil.getObject(json, "export"); - if (__exportJson != null) { - builder.export(Export.fromJson(__exportJson)); + JsonObject __exportObj = JsonUtil.getJsonObject(jsonObj, "export"); + if (__exportObj != null) { + builder.export(Export.fromJson(__exportObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/export/responses/ExportDeferredRevenueResponse.java b/src/main/java/com/chargebee/v4/models/export/responses/ExportDeferredRevenueResponse.java index 0c420988..24211123 100644 --- a/src/main/java/com/chargebee/v4/models/export/responses/ExportDeferredRevenueResponse.java +++ b/src/main/java/com/chargebee/v4/models/export/responses/ExportDeferredRevenueResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static ExportDeferredRevenueResponse fromJson(String json) { /** Parse JSON response into ExportDeferredRevenueResponse object with HTTP response. */ public static ExportDeferredRevenueResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __exportJson = JsonUtil.getObject(json, "export"); - if (__exportJson != null) { - builder.export(Export.fromJson(__exportJson)); + JsonObject __exportObj = JsonUtil.getJsonObject(jsonObj, "export"); + if (__exportObj != null) { + builder.export(Export.fromJson(__exportObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/export/responses/ExportDifferentialPricesResponse.java b/src/main/java/com/chargebee/v4/models/export/responses/ExportDifferentialPricesResponse.java index 913a74c3..aeefe1d9 100644 --- a/src/main/java/com/chargebee/v4/models/export/responses/ExportDifferentialPricesResponse.java +++ b/src/main/java/com/chargebee/v4/models/export/responses/ExportDifferentialPricesResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static ExportDifferentialPricesResponse fromJson(String json) { /** Parse JSON response into ExportDifferentialPricesResponse object with HTTP response. */ public static ExportDifferentialPricesResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __exportJson = JsonUtil.getObject(json, "export"); - if (__exportJson != null) { - builder.export(Export.fromJson(__exportJson)); + JsonObject __exportObj = JsonUtil.getJsonObject(jsonObj, "export"); + if (__exportObj != null) { + builder.export(Export.fromJson(__exportObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/export/responses/ExportInvoicesResponse.java b/src/main/java/com/chargebee/v4/models/export/responses/ExportInvoicesResponse.java index bb4212e4..a7578189 100644 --- a/src/main/java/com/chargebee/v4/models/export/responses/ExportInvoicesResponse.java +++ b/src/main/java/com/chargebee/v4/models/export/responses/ExportInvoicesResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -26,11 +27,12 @@ public static ExportInvoicesResponse fromJson(String json) { /** Parse JSON response into ExportInvoicesResponse object with HTTP response. */ public static ExportInvoicesResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __exportJson = JsonUtil.getObject(json, "export"); - if (__exportJson != null) { - builder.export(Export.fromJson(__exportJson)); + JsonObject __exportObj = JsonUtil.getJsonObject(jsonObj, "export"); + if (__exportObj != null) { + builder.export(Export.fromJson(__exportObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/export/responses/ExportItemFamiliesResponse.java b/src/main/java/com/chargebee/v4/models/export/responses/ExportItemFamiliesResponse.java index 9aa9728f..f699fdc2 100644 --- a/src/main/java/com/chargebee/v4/models/export/responses/ExportItemFamiliesResponse.java +++ b/src/main/java/com/chargebee/v4/models/export/responses/ExportItemFamiliesResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static ExportItemFamiliesResponse fromJson(String json) { /** Parse JSON response into ExportItemFamiliesResponse object with HTTP response. */ public static ExportItemFamiliesResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __exportJson = JsonUtil.getObject(json, "export"); - if (__exportJson != null) { - builder.export(Export.fromJson(__exportJson)); + JsonObject __exportObj = JsonUtil.getJsonObject(jsonObj, "export"); + if (__exportObj != null) { + builder.export(Export.fromJson(__exportObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/export/responses/ExportItemPricesResponse.java b/src/main/java/com/chargebee/v4/models/export/responses/ExportItemPricesResponse.java index 351a2f2d..4f8e924e 100644 --- a/src/main/java/com/chargebee/v4/models/export/responses/ExportItemPricesResponse.java +++ b/src/main/java/com/chargebee/v4/models/export/responses/ExportItemPricesResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static ExportItemPricesResponse fromJson(String json) { /** Parse JSON response into ExportItemPricesResponse object with HTTP response. */ public static ExportItemPricesResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __exportJson = JsonUtil.getObject(json, "export"); - if (__exportJson != null) { - builder.export(Export.fromJson(__exportJson)); + JsonObject __exportObj = JsonUtil.getJsonObject(jsonObj, "export"); + if (__exportObj != null) { + builder.export(Export.fromJson(__exportObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/export/responses/ExportItemsResponse.java b/src/main/java/com/chargebee/v4/models/export/responses/ExportItemsResponse.java index b5efd28d..dc2704b2 100644 --- a/src/main/java/com/chargebee/v4/models/export/responses/ExportItemsResponse.java +++ b/src/main/java/com/chargebee/v4/models/export/responses/ExportItemsResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** Immutable response object for ExportItems operation. Contains the response data from the API. */ @@ -24,11 +25,12 @@ public static ExportItemsResponse fromJson(String json) { /** Parse JSON response into ExportItemsResponse object with HTTP response. */ public static ExportItemsResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __exportJson = JsonUtil.getObject(json, "export"); - if (__exportJson != null) { - builder.export(Export.fromJson(__exportJson)); + JsonObject __exportObj = JsonUtil.getJsonObject(jsonObj, "export"); + if (__exportObj != null) { + builder.export(Export.fromJson(__exportObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/export/responses/ExportOrdersResponse.java b/src/main/java/com/chargebee/v4/models/export/responses/ExportOrdersResponse.java index 40cee4e8..695a675e 100644 --- a/src/main/java/com/chargebee/v4/models/export/responses/ExportOrdersResponse.java +++ b/src/main/java/com/chargebee/v4/models/export/responses/ExportOrdersResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -26,11 +27,12 @@ public static ExportOrdersResponse fromJson(String json) { /** Parse JSON response into ExportOrdersResponse object with HTTP response. */ public static ExportOrdersResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __exportJson = JsonUtil.getObject(json, "export"); - if (__exportJson != null) { - builder.export(Export.fromJson(__exportJson)); + JsonObject __exportObj = JsonUtil.getJsonObject(jsonObj, "export"); + if (__exportObj != null) { + builder.export(Export.fromJson(__exportObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/export/responses/ExportPlansResponse.java b/src/main/java/com/chargebee/v4/models/export/responses/ExportPlansResponse.java index d194b682..c55360d7 100644 --- a/src/main/java/com/chargebee/v4/models/export/responses/ExportPlansResponse.java +++ b/src/main/java/com/chargebee/v4/models/export/responses/ExportPlansResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** Immutable response object for ExportPlans operation. Contains the response data from the API. */ @@ -24,11 +25,12 @@ public static ExportPlansResponse fromJson(String json) { /** Parse JSON response into ExportPlansResponse object with HTTP response. */ public static ExportPlansResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __exportJson = JsonUtil.getObject(json, "export"); - if (__exportJson != null) { - builder.export(Export.fromJson(__exportJson)); + JsonObject __exportObj = JsonUtil.getJsonObject(jsonObj, "export"); + if (__exportObj != null) { + builder.export(Export.fromJson(__exportObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/export/responses/ExportPriceVariantsResponse.java b/src/main/java/com/chargebee/v4/models/export/responses/ExportPriceVariantsResponse.java index a3544937..4d1726c2 100644 --- a/src/main/java/com/chargebee/v4/models/export/responses/ExportPriceVariantsResponse.java +++ b/src/main/java/com/chargebee/v4/models/export/responses/ExportPriceVariantsResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static ExportPriceVariantsResponse fromJson(String json) { /** Parse JSON response into ExportPriceVariantsResponse object with HTTP response. */ public static ExportPriceVariantsResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __exportJson = JsonUtil.getObject(json, "export"); - if (__exportJson != null) { - builder.export(Export.fromJson(__exportJson)); + JsonObject __exportObj = JsonUtil.getJsonObject(jsonObj, "export"); + if (__exportObj != null) { + builder.export(Export.fromJson(__exportObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/export/responses/ExportRetrieveResponse.java b/src/main/java/com/chargebee/v4/models/export/responses/ExportRetrieveResponse.java index c418c3be..fc471fa0 100644 --- a/src/main/java/com/chargebee/v4/models/export/responses/ExportRetrieveResponse.java +++ b/src/main/java/com/chargebee/v4/models/export/responses/ExportRetrieveResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static ExportRetrieveResponse fromJson(String json) { /** Parse JSON response into ExportRetrieveResponse object with HTTP response. */ public static ExportRetrieveResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __exportJson = JsonUtil.getObject(json, "export"); - if (__exportJson != null) { - builder.export(Export.fromJson(__exportJson)); + JsonObject __exportObj = JsonUtil.getJsonObject(jsonObj, "export"); + if (__exportObj != null) { + builder.export(Export.fromJson(__exportObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/export/responses/ExportRevenueRecognitionResponse.java b/src/main/java/com/chargebee/v4/models/export/responses/ExportRevenueRecognitionResponse.java index 378e2d32..5b1b988f 100644 --- a/src/main/java/com/chargebee/v4/models/export/responses/ExportRevenueRecognitionResponse.java +++ b/src/main/java/com/chargebee/v4/models/export/responses/ExportRevenueRecognitionResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static ExportRevenueRecognitionResponse fromJson(String json) { /** Parse JSON response into ExportRevenueRecognitionResponse object with HTTP response. */ public static ExportRevenueRecognitionResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __exportJson = JsonUtil.getObject(json, "export"); - if (__exportJson != null) { - builder.export(Export.fromJson(__exportJson)); + JsonObject __exportObj = JsonUtil.getJsonObject(jsonObj, "export"); + if (__exportObj != null) { + builder.export(Export.fromJson(__exportObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/export/responses/ExportSubscriptionsResponse.java b/src/main/java/com/chargebee/v4/models/export/responses/ExportSubscriptionsResponse.java index 82152242..8d5d28ad 100644 --- a/src/main/java/com/chargebee/v4/models/export/responses/ExportSubscriptionsResponse.java +++ b/src/main/java/com/chargebee/v4/models/export/responses/ExportSubscriptionsResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static ExportSubscriptionsResponse fromJson(String json) { /** Parse JSON response into ExportSubscriptionsResponse object with HTTP response. */ public static ExportSubscriptionsResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __exportJson = JsonUtil.getObject(json, "export"); - if (__exportJson != null) { - builder.export(Export.fromJson(__exportJson)); + JsonObject __exportObj = JsonUtil.getJsonObject(jsonObj, "export"); + if (__exportObj != null) { + builder.export(Export.fromJson(__exportObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/export/responses/ExportTransactionsResponse.java b/src/main/java/com/chargebee/v4/models/export/responses/ExportTransactionsResponse.java index 09b7221b..75db094a 100644 --- a/src/main/java/com/chargebee/v4/models/export/responses/ExportTransactionsResponse.java +++ b/src/main/java/com/chargebee/v4/models/export/responses/ExportTransactionsResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static ExportTransactionsResponse fromJson(String json) { /** Parse JSON response into ExportTransactionsResponse object with HTTP response. */ public static ExportTransactionsResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __exportJson = JsonUtil.getObject(json, "export"); - if (__exportJson != null) { - builder.export(Export.fromJson(__exportJson)); + JsonObject __exportObj = JsonUtil.getJsonObject(jsonObj, "export"); + if (__exportObj != null) { + builder.export(Export.fromJson(__exportObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/feature/Feature.java b/src/main/java/com/chargebee/v4/models/feature/Feature.java index 50686e88..24f6c37e 100644 --- a/src/main/java/com/chargebee/v4/models/feature/Feature.java +++ b/src/main/java/com/chargebee/v4/models/feature/Feature.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.feature; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import java.sql.Timestamp; import java.util.List; @@ -149,9 +150,12 @@ public static Type fromString(String value) { } public static Feature fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Feature fromJson(JsonObject jsonObj) { Feature obj = new Feature(); - // Parse JSON to extract all keys for custom field extraction java.util.Set knownFields = new java.util.HashSet<>(); knownFields.add("id"); @@ -174,65 +178,31 @@ public static Feature fromJson(String json) { knownFields.add("levels"); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.name = JsonUtil.getString(json, "name"); + obj.name = JsonUtil.getString(jsonObj, "name"); - obj.description = JsonUtil.getString(json, "description"); + obj.description = JsonUtil.getString(jsonObj, "description"); - obj.status = Status.fromString(JsonUtil.getString(json, "status")); + obj.status = Status.fromString(JsonUtil.getString(jsonObj, "status")); - obj.type = Type.fromString(JsonUtil.getString(json, "type")); + obj.type = Type.fromString(JsonUtil.getString(jsonObj, "type")); - obj.unit = JsonUtil.getString(json, "unit"); + obj.unit = JsonUtil.getString(jsonObj, "unit"); - obj.resourceVersion = JsonUtil.getLong(json, "resource_version"); + obj.resourceVersion = JsonUtil.getLong(jsonObj, "resource_version"); - obj.updatedAt = JsonUtil.getTimestamp(json, "updated_at"); + obj.updatedAt = JsonUtil.getTimestamp(jsonObj, "updated_at"); - obj.createdAt = JsonUtil.getTimestamp(json, "created_at"); + obj.createdAt = JsonUtil.getTimestamp(jsonObj, "created_at"); - obj.levels = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "levels")).stream() - .map(Levels::fromJson) - .collect(java.util.stream.Collectors.toList()); + obj.levels = JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "levels"), Levels::fromJson); - // Extract custom fields (fields starting with cf_) - obj.customFields = extractCustomFields(json, knownFields); + obj.customFields = JsonUtil.extractCustomFields(jsonObj, knownFields); return obj; } - /** - * Helper method to extract custom fields from JSON. Custom fields are fields that start with - * "cf_" and are not in the known fields set. - * - * @param json JSON string to parse - * @param knownFields set of known field names - * @return map of custom fields - */ - private static java.util.Map extractCustomFields( - String json, java.util.Set knownFields) { - java.util.Map customFields = new java.util.HashMap<>(); - try { - // Parse the entire JSON as a map - java.util.Map allFields = JsonUtil.parseJsonObjectToMap(json); - if (allFields != null) { - for (java.util.Map.Entry entry : allFields.entrySet()) { - String key = entry.getKey(); - // Include fields that start with "cf_" and are not in knownFields - if (key != null && key.startsWith("cf_") && !knownFields.contains(key)) { - customFields.put( - key, entry.getValue() != null ? String.valueOf(entry.getValue()) : null); - } - } - } - } catch (Exception e) { - // If parsing fails, return empty map - } - return customFields; - } - @Override public String toString() { return "Feature{" @@ -321,15 +291,19 @@ public Boolean getIsUnlimited() { } public static Levels fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Levels fromJson(JsonObject jsonObj) { Levels obj = new Levels(); - obj.name = JsonUtil.getString(json, "name"); + obj.name = JsonUtil.getString(jsonObj, "name"); - obj.value = JsonUtil.getString(json, "value"); + obj.value = JsonUtil.getString(jsonObj, "value"); - obj.level = JsonUtil.getInteger(json, "level"); + obj.level = JsonUtil.getInteger(jsonObj, "level"); - obj.isUnlimited = JsonUtil.getBoolean(json, "is_unlimited"); + obj.isUnlimited = JsonUtil.getBoolean(jsonObj, "is_unlimited"); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/feature/responses/FeatureActivateResponse.java b/src/main/java/com/chargebee/v4/models/feature/responses/FeatureActivateResponse.java index c9b910da..b96156e4 100644 --- a/src/main/java/com/chargebee/v4/models/feature/responses/FeatureActivateResponse.java +++ b/src/main/java/com/chargebee/v4/models/feature/responses/FeatureActivateResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -26,11 +27,12 @@ public static FeatureActivateResponse fromJson(String json) { /** Parse JSON response into FeatureActivateResponse object with HTTP response. */ public static FeatureActivateResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __featureJson = JsonUtil.getObject(json, "feature"); - if (__featureJson != null) { - builder.feature(Feature.fromJson(__featureJson)); + JsonObject __featureObj = JsonUtil.getJsonObject(jsonObj, "feature"); + if (__featureObj != null) { + builder.feature(Feature.fromJson(__featureObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/feature/responses/FeatureArchiveResponse.java b/src/main/java/com/chargebee/v4/models/feature/responses/FeatureArchiveResponse.java index c581737f..daa10616 100644 --- a/src/main/java/com/chargebee/v4/models/feature/responses/FeatureArchiveResponse.java +++ b/src/main/java/com/chargebee/v4/models/feature/responses/FeatureArchiveResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -26,11 +27,12 @@ public static FeatureArchiveResponse fromJson(String json) { /** Parse JSON response into FeatureArchiveResponse object with HTTP response. */ public static FeatureArchiveResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __featureJson = JsonUtil.getObject(json, "feature"); - if (__featureJson != null) { - builder.feature(Feature.fromJson(__featureJson)); + JsonObject __featureObj = JsonUtil.getJsonObject(jsonObj, "feature"); + if (__featureObj != null) { + builder.feature(Feature.fromJson(__featureObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/feature/responses/FeatureCreateResponse.java b/src/main/java/com/chargebee/v4/models/feature/responses/FeatureCreateResponse.java index 78930d7a..8186987c 100644 --- a/src/main/java/com/chargebee/v4/models/feature/responses/FeatureCreateResponse.java +++ b/src/main/java/com/chargebee/v4/models/feature/responses/FeatureCreateResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -26,11 +27,12 @@ public static FeatureCreateResponse fromJson(String json) { /** Parse JSON response into FeatureCreateResponse object with HTTP response. */ public static FeatureCreateResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __featureJson = JsonUtil.getObject(json, "feature"); - if (__featureJson != null) { - builder.feature(Feature.fromJson(__featureJson)); + JsonObject __featureObj = JsonUtil.getJsonObject(jsonObj, "feature"); + if (__featureObj != null) { + builder.feature(Feature.fromJson(__featureObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/feature/responses/FeatureDeleteResponse.java b/src/main/java/com/chargebee/v4/models/feature/responses/FeatureDeleteResponse.java index 698f8e87..53b6e0c6 100644 --- a/src/main/java/com/chargebee/v4/models/feature/responses/FeatureDeleteResponse.java +++ b/src/main/java/com/chargebee/v4/models/feature/responses/FeatureDeleteResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -26,11 +27,12 @@ public static FeatureDeleteResponse fromJson(String json) { /** Parse JSON response into FeatureDeleteResponse object with HTTP response. */ public static FeatureDeleteResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __featureJson = JsonUtil.getObject(json, "feature"); - if (__featureJson != null) { - builder.feature(Feature.fromJson(__featureJson)); + JsonObject __featureObj = JsonUtil.getJsonObject(jsonObj, "feature"); + if (__featureObj != null) { + builder.feature(Feature.fromJson(__featureObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/feature/responses/FeatureListResponse.java b/src/main/java/com/chargebee/v4/models/feature/responses/FeatureListResponse.java index 131d4770..15165683 100644 --- a/src/main/java/com/chargebee/v4/models/feature/responses/FeatureListResponse.java +++ b/src/main/java/com/chargebee/v4/models/feature/responses/FeatureListResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.exceptions.ChargebeeException; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; import com.chargebee.v4.services.FeatureService; import com.chargebee.v4.models.feature.params.FeatureListParams; @@ -43,13 +44,12 @@ private FeatureListResponse( */ public static FeatureListResponse fromJson(String json) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(FeatureListItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "list"), FeatureListItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new FeatureListResponse(list, nextOffset, null, null, null); } catch (Exception e) { @@ -67,13 +67,12 @@ public static FeatureListResponse fromJson( FeatureListParams originalParams, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(FeatureListItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "list"), FeatureListItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new FeatureListResponse(list, nextOffset, service, originalParams, httpResponse); } catch (Exception e) { @@ -173,11 +172,15 @@ public Feature getFeature() { } public static FeatureListItem fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static FeatureListItem fromJson(JsonObject jsonObj) { FeatureListItem item = new FeatureListItem(); - String __featureJson = JsonUtil.getObject(json, "feature"); - if (__featureJson != null) { - item.feature = Feature.fromJson(__featureJson); + JsonObject __featureObj = JsonUtil.getJsonObject(jsonObj, "feature"); + if (__featureObj != null) { + item.feature = Feature.fromJson(__featureObj); } return item; diff --git a/src/main/java/com/chargebee/v4/models/feature/responses/FeatureReactivateResponse.java b/src/main/java/com/chargebee/v4/models/feature/responses/FeatureReactivateResponse.java index ae2d6908..bb96b767 100644 --- a/src/main/java/com/chargebee/v4/models/feature/responses/FeatureReactivateResponse.java +++ b/src/main/java/com/chargebee/v4/models/feature/responses/FeatureReactivateResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static FeatureReactivateResponse fromJson(String json) { /** Parse JSON response into FeatureReactivateResponse object with HTTP response. */ public static FeatureReactivateResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __featureJson = JsonUtil.getObject(json, "feature"); - if (__featureJson != null) { - builder.feature(Feature.fromJson(__featureJson)); + JsonObject __featureObj = JsonUtil.getJsonObject(jsonObj, "feature"); + if (__featureObj != null) { + builder.feature(Feature.fromJson(__featureObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/feature/responses/FeatureRetrieveResponse.java b/src/main/java/com/chargebee/v4/models/feature/responses/FeatureRetrieveResponse.java index b3a81f27..8d37f44e 100644 --- a/src/main/java/com/chargebee/v4/models/feature/responses/FeatureRetrieveResponse.java +++ b/src/main/java/com/chargebee/v4/models/feature/responses/FeatureRetrieveResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static FeatureRetrieveResponse fromJson(String json) { /** Parse JSON response into FeatureRetrieveResponse object with HTTP response. */ public static FeatureRetrieveResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __featureJson = JsonUtil.getObject(json, "feature"); - if (__featureJson != null) { - builder.feature(Feature.fromJson(__featureJson)); + JsonObject __featureObj = JsonUtil.getJsonObject(jsonObj, "feature"); + if (__featureObj != null) { + builder.feature(Feature.fromJson(__featureObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/feature/responses/FeatureUpdateResponse.java b/src/main/java/com/chargebee/v4/models/feature/responses/FeatureUpdateResponse.java index 6af174be..2a652efa 100644 --- a/src/main/java/com/chargebee/v4/models/feature/responses/FeatureUpdateResponse.java +++ b/src/main/java/com/chargebee/v4/models/feature/responses/FeatureUpdateResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -26,11 +27,12 @@ public static FeatureUpdateResponse fromJson(String json) { /** Parse JSON response into FeatureUpdateResponse object with HTTP response. */ public static FeatureUpdateResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __featureJson = JsonUtil.getObject(json, "feature"); - if (__featureJson != null) { - builder.feature(Feature.fromJson(__featureJson)); + JsonObject __featureObj = JsonUtil.getJsonObject(jsonObj, "feature"); + if (__featureObj != null) { + builder.feature(Feature.fromJson(__featureObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/fullExport/responses/FullExportStatusResponse.java b/src/main/java/com/chargebee/v4/models/fullExport/responses/FullExportStatusResponse.java index c14cf570..0aef6433 100644 --- a/src/main/java/com/chargebee/v4/models/fullExport/responses/FullExportStatusResponse.java +++ b/src/main/java/com/chargebee/v4/models/fullExport/responses/FullExportStatusResponse.java @@ -2,6 +2,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -25,9 +26,10 @@ public static FullExportStatusResponse fromJson(String json) { /** Parse JSON response into FullExportStatusResponse object with HTTP response. */ public static FullExportStatusResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - builder.fullExport(JsonUtil.getObject(json, "full_export")); + builder.fullExport(JsonUtil.getObject(jsonObj, "full_export")); builder.httpResponse(httpResponse); return builder.build(); diff --git a/src/main/java/com/chargebee/v4/models/gatewayErrorDetail/GatewayErrorDetail.java b/src/main/java/com/chargebee/v4/models/gatewayErrorDetail/GatewayErrorDetail.java index 78008a62..5fc6b907 100644 --- a/src/main/java/com/chargebee/v4/models/gatewayErrorDetail/GatewayErrorDetail.java +++ b/src/main/java/com/chargebee/v4/models/gatewayErrorDetail/GatewayErrorDetail.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.gatewayErrorDetail; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; public class GatewayErrorDetail { @@ -88,37 +89,41 @@ public String getProcessorAdviceCode() { } public static GatewayErrorDetail fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static GatewayErrorDetail fromJson(JsonObject jsonObj) { GatewayErrorDetail obj = new GatewayErrorDetail(); - obj.requestId = JsonUtil.getString(json, "request_id"); + obj.requestId = JsonUtil.getString(jsonObj, "request_id"); - obj.errorCategory = JsonUtil.getString(json, "error_category"); + obj.errorCategory = JsonUtil.getString(jsonObj, "error_category"); - obj.errorCode = JsonUtil.getString(json, "error_code"); + obj.errorCode = JsonUtil.getString(jsonObj, "error_code"); - obj.errorMessage = JsonUtil.getString(json, "error_message"); + obj.errorMessage = JsonUtil.getString(jsonObj, "error_message"); - obj.declineCode = JsonUtil.getString(json, "decline_code"); + obj.declineCode = JsonUtil.getString(jsonObj, "decline_code"); - obj.declineMessage = JsonUtil.getString(json, "decline_message"); + obj.declineMessage = JsonUtil.getString(jsonObj, "decline_message"); - obj.networkErrorCode = JsonUtil.getString(json, "network_error_code"); + obj.networkErrorCode = JsonUtil.getString(jsonObj, "network_error_code"); - obj.networkErrorMessage = JsonUtil.getString(json, "network_error_message"); + obj.networkErrorMessage = JsonUtil.getString(jsonObj, "network_error_message"); - obj.errorField = JsonUtil.getString(json, "error_field"); + obj.errorField = JsonUtil.getString(jsonObj, "error_field"); - obj.recommendationCode = JsonUtil.getString(json, "recommendation_code"); + obj.recommendationCode = JsonUtil.getString(jsonObj, "recommendation_code"); - obj.recommendationMessage = JsonUtil.getString(json, "recommendation_message"); + obj.recommendationMessage = JsonUtil.getString(jsonObj, "recommendation_message"); - obj.processorErrorCode = JsonUtil.getString(json, "processor_error_code"); + obj.processorErrorCode = JsonUtil.getString(jsonObj, "processor_error_code"); - obj.processorErrorMessage = JsonUtil.getString(json, "processor_error_message"); + obj.processorErrorMessage = JsonUtil.getString(jsonObj, "processor_error_message"); - obj.errorCauseId = JsonUtil.getString(json, "error_cause_id"); + obj.errorCauseId = JsonUtil.getString(jsonObj, "error_cause_id"); - obj.processorAdviceCode = JsonUtil.getString(json, "processor_advice_code"); + obj.processorAdviceCode = JsonUtil.getString(jsonObj, "processor_advice_code"); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/gift/Gift.java b/src/main/java/com/chargebee/v4/models/gift/Gift.java index ca5f5a7f..a8457ef3 100644 --- a/src/main/java/com/chargebee/v4/models/gift/Gift.java +++ b/src/main/java/com/chargebee/v4/models/gift/Gift.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.gift; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import java.sql.Timestamp; import java.util.List; @@ -104,38 +105,41 @@ public static Status fromString(String value) { } public static Gift fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Gift fromJson(JsonObject jsonObj) { Gift obj = new Gift(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.status = Status.fromString(JsonUtil.getString(json, "status")); + obj.status = Status.fromString(JsonUtil.getString(jsonObj, "status")); - obj.scheduledAt = JsonUtil.getTimestamp(json, "scheduled_at"); + obj.scheduledAt = JsonUtil.getTimestamp(jsonObj, "scheduled_at"); - obj.autoClaim = JsonUtil.getBoolean(json, "auto_claim"); + obj.autoClaim = JsonUtil.getBoolean(jsonObj, "auto_claim"); - obj.noExpiry = JsonUtil.getBoolean(json, "no_expiry"); + obj.noExpiry = JsonUtil.getBoolean(jsonObj, "no_expiry"); - obj.claimExpiryDate = JsonUtil.getTimestamp(json, "claim_expiry_date"); + obj.claimExpiryDate = JsonUtil.getTimestamp(jsonObj, "claim_expiry_date"); - obj.resourceVersion = JsonUtil.getLong(json, "resource_version"); + obj.resourceVersion = JsonUtil.getLong(jsonObj, "resource_version"); - obj.updatedAt = JsonUtil.getTimestamp(json, "updated_at"); + obj.updatedAt = JsonUtil.getTimestamp(jsonObj, "updated_at"); - String __gifterJson = JsonUtil.getObject(json, "gifter"); - if (__gifterJson != null) { - obj.gifter = Gifter.fromJson(__gifterJson); + JsonObject __gifterObj = JsonUtil.getJsonObject(jsonObj, "gifter"); + if (__gifterObj != null) { + obj.gifter = Gifter.fromJson(__gifterObj); } - String __giftReceiverJson = JsonUtil.getObject(json, "gift_receiver"); - if (__giftReceiverJson != null) { - obj.giftReceiver = GiftReceiver.fromJson(__giftReceiverJson); + JsonObject __giftReceiverObj = JsonUtil.getJsonObject(jsonObj, "gift_receiver"); + if (__giftReceiverObj != null) { + obj.giftReceiver = GiftReceiver.fromJson(__giftReceiverObj); } obj.giftTimelines = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "gift_timelines")).stream() - .map(GiftTimelines::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "gift_timelines"), GiftTimelines::fromJson); return obj; } @@ -228,15 +232,19 @@ public String getNote() { } public static Gifter fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Gifter fromJson(JsonObject jsonObj) { Gifter obj = new Gifter(); - obj.customerId = JsonUtil.getString(json, "customer_id"); + obj.customerId = JsonUtil.getString(jsonObj, "customer_id"); - obj.invoiceId = JsonUtil.getString(json, "invoice_id"); + obj.invoiceId = JsonUtil.getString(jsonObj, "invoice_id"); - obj.signature = JsonUtil.getString(json, "signature"); + obj.signature = JsonUtil.getString(jsonObj, "signature"); - obj.note = JsonUtil.getString(json, "note"); + obj.note = JsonUtil.getString(jsonObj, "note"); return obj; } @@ -303,17 +311,21 @@ public String getEmail() { } public static GiftReceiver fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static GiftReceiver fromJson(JsonObject jsonObj) { GiftReceiver obj = new GiftReceiver(); - obj.customerId = JsonUtil.getString(json, "customer_id"); + obj.customerId = JsonUtil.getString(jsonObj, "customer_id"); - obj.subscriptionId = JsonUtil.getString(json, "subscription_id"); + obj.subscriptionId = JsonUtil.getString(jsonObj, "subscription_id"); - obj.firstName = JsonUtil.getString(json, "first_name"); + obj.firstName = JsonUtil.getString(jsonObj, "first_name"); - obj.lastName = JsonUtil.getString(json, "last_name"); + obj.lastName = JsonUtil.getString(jsonObj, "last_name"); - obj.email = JsonUtil.getString(json, "email"); + obj.email = JsonUtil.getString(jsonObj, "email"); return obj; } @@ -402,11 +414,15 @@ public static Status fromString(String value) { } public static GiftTimelines fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static GiftTimelines fromJson(JsonObject jsonObj) { GiftTimelines obj = new GiftTimelines(); - obj.status = Status.fromString(JsonUtil.getString(json, "status")); + obj.status = Status.fromString(JsonUtil.getString(jsonObj, "status")); - obj.occurredAt = JsonUtil.getTimestamp(json, "occurred_at"); + obj.occurredAt = JsonUtil.getTimestamp(jsonObj, "occurred_at"); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/gift/responses/GiftCancelResponse.java b/src/main/java/com/chargebee/v4/models/gift/responses/GiftCancelResponse.java index addfa281..76bd466b 100644 --- a/src/main/java/com/chargebee/v4/models/gift/responses/GiftCancelResponse.java +++ b/src/main/java/com/chargebee/v4/models/gift/responses/GiftCancelResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** Immutable response object for GiftCancel operation. Contains the response data from the API. */ @@ -30,16 +31,17 @@ public static GiftCancelResponse fromJson(String json) { /** Parse JSON response into GiftCancelResponse object with HTTP response. */ public static GiftCancelResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __giftJson = JsonUtil.getObject(json, "gift"); - if (__giftJson != null) { - builder.gift(Gift.fromJson(__giftJson)); + JsonObject __giftObj = JsonUtil.getJsonObject(jsonObj, "gift"); + if (__giftObj != null) { + builder.gift(Gift.fromJson(__giftObj)); } - String __subscriptionJson = JsonUtil.getObject(json, "subscription"); - if (__subscriptionJson != null) { - builder.subscription(Subscription.fromJson(__subscriptionJson)); + JsonObject __subscriptionObj = JsonUtil.getJsonObject(jsonObj, "subscription"); + if (__subscriptionObj != null) { + builder.subscription(Subscription.fromJson(__subscriptionObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/gift/responses/GiftClaimResponse.java b/src/main/java/com/chargebee/v4/models/gift/responses/GiftClaimResponse.java index 2a8a6b73..c6c50261 100644 --- a/src/main/java/com/chargebee/v4/models/gift/responses/GiftClaimResponse.java +++ b/src/main/java/com/chargebee/v4/models/gift/responses/GiftClaimResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** Immutable response object for GiftClaim operation. Contains the response data from the API. */ @@ -30,16 +31,17 @@ public static GiftClaimResponse fromJson(String json) { /** Parse JSON response into GiftClaimResponse object with HTTP response. */ public static GiftClaimResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __giftJson = JsonUtil.getObject(json, "gift"); - if (__giftJson != null) { - builder.gift(Gift.fromJson(__giftJson)); + JsonObject __giftObj = JsonUtil.getJsonObject(jsonObj, "gift"); + if (__giftObj != null) { + builder.gift(Gift.fromJson(__giftObj)); } - String __subscriptionJson = JsonUtil.getObject(json, "subscription"); - if (__subscriptionJson != null) { - builder.subscription(Subscription.fromJson(__subscriptionJson)); + JsonObject __subscriptionObj = JsonUtil.getJsonObject(jsonObj, "subscription"); + if (__subscriptionObj != null) { + builder.subscription(Subscription.fromJson(__subscriptionObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/gift/responses/GiftCreateForItemsResponse.java b/src/main/java/com/chargebee/v4/models/gift/responses/GiftCreateForItemsResponse.java index 848cd039..1af67f5d 100644 --- a/src/main/java/com/chargebee/v4/models/gift/responses/GiftCreateForItemsResponse.java +++ b/src/main/java/com/chargebee/v4/models/gift/responses/GiftCreateForItemsResponse.java @@ -8,6 +8,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -39,21 +40,22 @@ public static GiftCreateForItemsResponse fromJson(String json) { /** Parse JSON response into GiftCreateForItemsResponse object with HTTP response. */ public static GiftCreateForItemsResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __giftJson = JsonUtil.getObject(json, "gift"); - if (__giftJson != null) { - builder.gift(Gift.fromJson(__giftJson)); + JsonObject __giftObj = JsonUtil.getJsonObject(jsonObj, "gift"); + if (__giftObj != null) { + builder.gift(Gift.fromJson(__giftObj)); } - String __subscriptionJson = JsonUtil.getObject(json, "subscription"); - if (__subscriptionJson != null) { - builder.subscription(Subscription.fromJson(__subscriptionJson)); + JsonObject __subscriptionObj = JsonUtil.getJsonObject(jsonObj, "subscription"); + if (__subscriptionObj != null) { + builder.subscription(Subscription.fromJson(__subscriptionObj)); } - String __invoiceJson = JsonUtil.getObject(json, "invoice"); - if (__invoiceJson != null) { - builder.invoice(Invoice.fromJson(__invoiceJson)); + JsonObject __invoiceObj = JsonUtil.getJsonObject(jsonObj, "invoice"); + if (__invoiceObj != null) { + builder.invoice(Invoice.fromJson(__invoiceObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/gift/responses/GiftCreateResponse.java b/src/main/java/com/chargebee/v4/models/gift/responses/GiftCreateResponse.java index c06e5c09..b7383862 100644 --- a/src/main/java/com/chargebee/v4/models/gift/responses/GiftCreateResponse.java +++ b/src/main/java/com/chargebee/v4/models/gift/responses/GiftCreateResponse.java @@ -8,6 +8,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** Immutable response object for GiftCreate operation. Contains the response data from the API. */ @@ -36,21 +37,22 @@ public static GiftCreateResponse fromJson(String json) { /** Parse JSON response into GiftCreateResponse object with HTTP response. */ public static GiftCreateResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __giftJson = JsonUtil.getObject(json, "gift"); - if (__giftJson != null) { - builder.gift(Gift.fromJson(__giftJson)); + JsonObject __giftObj = JsonUtil.getJsonObject(jsonObj, "gift"); + if (__giftObj != null) { + builder.gift(Gift.fromJson(__giftObj)); } - String __subscriptionJson = JsonUtil.getObject(json, "subscription"); - if (__subscriptionJson != null) { - builder.subscription(Subscription.fromJson(__subscriptionJson)); + JsonObject __subscriptionObj = JsonUtil.getJsonObject(jsonObj, "subscription"); + if (__subscriptionObj != null) { + builder.subscription(Subscription.fromJson(__subscriptionObj)); } - String __invoiceJson = JsonUtil.getObject(json, "invoice"); - if (__invoiceJson != null) { - builder.invoice(Invoice.fromJson(__invoiceJson)); + JsonObject __invoiceObj = JsonUtil.getJsonObject(jsonObj, "invoice"); + if (__invoiceObj != null) { + builder.invoice(Invoice.fromJson(__invoiceObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/gift/responses/GiftListResponse.java b/src/main/java/com/chargebee/v4/models/gift/responses/GiftListResponse.java index 90f66f38..2b2536ee 100644 --- a/src/main/java/com/chargebee/v4/models/gift/responses/GiftListResponse.java +++ b/src/main/java/com/chargebee/v4/models/gift/responses/GiftListResponse.java @@ -8,6 +8,7 @@ import com.chargebee.v4.exceptions.ChargebeeException; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; import com.chargebee.v4.services.GiftService; import com.chargebee.v4.models.gift.params.GiftListParams; @@ -45,13 +46,12 @@ private GiftListResponse( */ public static GiftListResponse fromJson(String json) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(GiftListItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "list"), GiftListItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new GiftListResponse(list, nextOffset, null, null, null); } catch (Exception e) { @@ -66,13 +66,12 @@ public static GiftListResponse fromJson(String json) { public static GiftListResponse fromJson( String json, GiftService service, GiftListParams originalParams, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(GiftListItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "list"), GiftListItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new GiftListResponse(list, nextOffset, service, originalParams, httpResponse); } catch (Exception e) { @@ -178,16 +177,20 @@ public Subscription getSubscription() { } public static GiftListItem fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static GiftListItem fromJson(JsonObject jsonObj) { GiftListItem item = new GiftListItem(); - String __giftJson = JsonUtil.getObject(json, "gift"); - if (__giftJson != null) { - item.gift = Gift.fromJson(__giftJson); + JsonObject __giftObj = JsonUtil.getJsonObject(jsonObj, "gift"); + if (__giftObj != null) { + item.gift = Gift.fromJson(__giftObj); } - String __subscriptionJson = JsonUtil.getObject(json, "subscription"); - if (__subscriptionJson != null) { - item.subscription = Subscription.fromJson(__subscriptionJson); + JsonObject __subscriptionObj = JsonUtil.getJsonObject(jsonObj, "subscription"); + if (__subscriptionObj != null) { + item.subscription = Subscription.fromJson(__subscriptionObj); } return item; diff --git a/src/main/java/com/chargebee/v4/models/gift/responses/GiftRetrieveResponse.java b/src/main/java/com/chargebee/v4/models/gift/responses/GiftRetrieveResponse.java index b17650d4..f963e90b 100644 --- a/src/main/java/com/chargebee/v4/models/gift/responses/GiftRetrieveResponse.java +++ b/src/main/java/com/chargebee/v4/models/gift/responses/GiftRetrieveResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -33,16 +34,17 @@ public static GiftRetrieveResponse fromJson(String json) { /** Parse JSON response into GiftRetrieveResponse object with HTTP response. */ public static GiftRetrieveResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __giftJson = JsonUtil.getObject(json, "gift"); - if (__giftJson != null) { - builder.gift(Gift.fromJson(__giftJson)); + JsonObject __giftObj = JsonUtil.getJsonObject(jsonObj, "gift"); + if (__giftObj != null) { + builder.gift(Gift.fromJson(__giftObj)); } - String __subscriptionJson = JsonUtil.getObject(json, "subscription"); - if (__subscriptionJson != null) { - builder.subscription(Subscription.fromJson(__subscriptionJson)); + JsonObject __subscriptionObj = JsonUtil.getJsonObject(jsonObj, "subscription"); + if (__subscriptionObj != null) { + builder.subscription(Subscription.fromJson(__subscriptionObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/gift/responses/UpdateGiftResponse.java b/src/main/java/com/chargebee/v4/models/gift/responses/UpdateGiftResponse.java index 2e7edc88..dfc68126 100644 --- a/src/main/java/com/chargebee/v4/models/gift/responses/UpdateGiftResponse.java +++ b/src/main/java/com/chargebee/v4/models/gift/responses/UpdateGiftResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** Immutable response object for UpdateGift operation. Contains the response data from the API. */ @@ -30,16 +31,17 @@ public static UpdateGiftResponse fromJson(String json) { /** Parse JSON response into UpdateGiftResponse object with HTTP response. */ public static UpdateGiftResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __giftJson = JsonUtil.getObject(json, "gift"); - if (__giftJson != null) { - builder.gift(Gift.fromJson(__giftJson)); + JsonObject __giftObj = JsonUtil.getJsonObject(jsonObj, "gift"); + if (__giftObj != null) { + builder.gift(Gift.fromJson(__giftObj)); } - String __subscriptionJson = JsonUtil.getObject(json, "subscription"); - if (__subscriptionJson != null) { - builder.subscription(Subscription.fromJson(__subscriptionJson)); + JsonObject __subscriptionObj = JsonUtil.getJsonObject(jsonObj, "subscription"); + if (__subscriptionObj != null) { + builder.subscription(Subscription.fromJson(__subscriptionObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/hierarchy/Hierarchy.java b/src/main/java/com/chargebee/v4/models/hierarchy/Hierarchy.java index 2bca689a..de6b6895 100644 --- a/src/main/java/com/chargebee/v4/models/hierarchy/Hierarchy.java +++ b/src/main/java/com/chargebee/v4/models/hierarchy/Hierarchy.java @@ -8,6 +8,8 @@ package com.chargebee.v4.models.hierarchy; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonArray; +import com.google.gson.JsonObject; import java.util.List; public class Hierarchy { @@ -44,19 +46,26 @@ public List getChildrenIds() { } public static Hierarchy fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Hierarchy fromJson(JsonObject jsonObj) { Hierarchy obj = new Hierarchy(); - obj.customerId = JsonUtil.getString(json, "customer_id"); + obj.customerId = JsonUtil.getString(jsonObj, "customer_id"); - obj.parentId = JsonUtil.getString(json, "parent_id"); + obj.parentId = JsonUtil.getString(jsonObj, "parent_id"); - obj.paymentOwnerId = JsonUtil.getString(json, "payment_owner_id"); + obj.paymentOwnerId = JsonUtil.getString(jsonObj, "payment_owner_id"); - obj.invoiceOwnerId = JsonUtil.getString(json, "invoice_owner_id"); + obj.invoiceOwnerId = JsonUtil.getString(jsonObj, "invoice_owner_id"); - obj.hasChildren = JsonUtil.getBoolean(json, "has_children"); + obj.hasChildren = JsonUtil.getBoolean(jsonObj, "has_children"); - obj.childrenIds = JsonUtil.parseArrayOfString(JsonUtil.getArray(json, "children_ids")); + JsonArray __childrenIdsArr = JsonUtil.getJsonArray(jsonObj, "children_ids"); + if (__childrenIdsArr != null) { + obj.childrenIds = JsonUtil.parseArrayOfString(__childrenIdsArr); + } return obj; } diff --git a/src/main/java/com/chargebee/v4/models/hostedPage/HostedPage.java b/src/main/java/com/chargebee/v4/models/hostedPage/HostedPage.java index a7615404..34e4ac6c 100644 --- a/src/main/java/com/chargebee/v4/models/hostedPage/HostedPage.java +++ b/src/main/java/com/chargebee/v4/models/hostedPage/HostedPage.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.hostedPage; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import java.sql.Timestamp; public class HostedPage { @@ -199,43 +200,47 @@ public static FailureReason fromString(String value) { } public static HostedPage fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static HostedPage fromJson(JsonObject jsonObj) { HostedPage obj = new HostedPage(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.type = Type.fromString(JsonUtil.getString(json, "type")); + obj.type = Type.fromString(JsonUtil.getString(jsonObj, "type")); - obj.url = JsonUtil.getString(json, "url"); + obj.url = JsonUtil.getString(jsonObj, "url"); - obj.state = State.fromString(JsonUtil.getString(json, "state")); + obj.state = State.fromString(JsonUtil.getString(jsonObj, "state")); - obj.failureReason = FailureReason.fromString(JsonUtil.getString(json, "failure_reason")); + obj.failureReason = FailureReason.fromString(JsonUtil.getString(jsonObj, "failure_reason")); - obj.passThruContent = JsonUtil.getString(json, "pass_thru_content"); + obj.passThruContent = JsonUtil.getString(jsonObj, "pass_thru_content"); - obj.createdAt = JsonUtil.getTimestamp(json, "created_at"); + obj.createdAt = JsonUtil.getTimestamp(jsonObj, "created_at"); - obj.expiresAt = JsonUtil.getTimestamp(json, "expires_at"); + obj.expiresAt = JsonUtil.getTimestamp(jsonObj, "expires_at"); - String __contentJson = JsonUtil.getObject(json, "content"); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); obj.content = - __contentJson != null - ? JsonUtil.parseJsonObjectToMap(__contentJson) + __contentObj != null + ? JsonUtil.parseJsonObjectToMap(__contentObj) : new java.util.HashMap<>(); - obj.updatedAt = JsonUtil.getTimestamp(json, "updated_at"); + obj.updatedAt = JsonUtil.getTimestamp(jsonObj, "updated_at"); - obj.resourceVersion = JsonUtil.getLong(json, "resource_version"); + obj.resourceVersion = JsonUtil.getLong(jsonObj, "resource_version"); - String __checkoutInfoJson = JsonUtil.getObject(json, "checkout_info"); + JsonObject __checkoutInfoObj = JsonUtil.getJsonObject(jsonObj, "checkout_info"); obj.checkoutInfo = - __checkoutInfoJson != null - ? JsonUtil.parseJsonObjectToMap(__checkoutInfoJson) + __checkoutInfoObj != null + ? JsonUtil.parseJsonObjectToMap(__checkoutInfoObj) : new java.util.HashMap<>(); - obj.businessEntityId = JsonUtil.getString(json, "business_entity_id"); + obj.businessEntityId = JsonUtil.getString(jsonObj, "business_entity_id"); - obj.embed = JsonUtil.getBoolean(json, "embed"); + obj.embed = JsonUtil.getBoolean(jsonObj, "embed"); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/hostedPage/responses/HostedPageAcceptQuoteResponse.java b/src/main/java/com/chargebee/v4/models/hostedPage/responses/HostedPageAcceptQuoteResponse.java index 38d5ff19..82faa2ac 100644 --- a/src/main/java/com/chargebee/v4/models/hostedPage/responses/HostedPageAcceptQuoteResponse.java +++ b/src/main/java/com/chargebee/v4/models/hostedPage/responses/HostedPageAcceptQuoteResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static HostedPageAcceptQuoteResponse fromJson(String json) { /** Parse JSON response into HostedPageAcceptQuoteResponse object with HTTP response. */ public static HostedPageAcceptQuoteResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __hostedPageJson = JsonUtil.getObject(json, "hosted_page"); - if (__hostedPageJson != null) { - builder.hostedPage(HostedPage.fromJson(__hostedPageJson)); + JsonObject __hostedPageObj = JsonUtil.getJsonObject(jsonObj, "hosted_page"); + if (__hostedPageObj != null) { + builder.hostedPage(HostedPage.fromJson(__hostedPageObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/hostedPage/responses/HostedPageAcknowledgeResponse.java b/src/main/java/com/chargebee/v4/models/hostedPage/responses/HostedPageAcknowledgeResponse.java index 32f9ef22..cb1bbe73 100644 --- a/src/main/java/com/chargebee/v4/models/hostedPage/responses/HostedPageAcknowledgeResponse.java +++ b/src/main/java/com/chargebee/v4/models/hostedPage/responses/HostedPageAcknowledgeResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static HostedPageAcknowledgeResponse fromJson(String json) { /** Parse JSON response into HostedPageAcknowledgeResponse object with HTTP response. */ public static HostedPageAcknowledgeResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __hostedPageJson = JsonUtil.getObject(json, "hosted_page"); - if (__hostedPageJson != null) { - builder.hostedPage(HostedPage.fromJson(__hostedPageJson)); + JsonObject __hostedPageObj = JsonUtil.getJsonObject(jsonObj, "hosted_page"); + if (__hostedPageObj != null) { + builder.hostedPage(HostedPage.fromJson(__hostedPageObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/hostedPage/responses/HostedPageCheckoutExistingForItemsResponse.java b/src/main/java/com/chargebee/v4/models/hostedPage/responses/HostedPageCheckoutExistingForItemsResponse.java index caa5fb10..40f414a7 100644 --- a/src/main/java/com/chargebee/v4/models/hostedPage/responses/HostedPageCheckoutExistingForItemsResponse.java +++ b/src/main/java/com/chargebee/v4/models/hostedPage/responses/HostedPageCheckoutExistingForItemsResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -30,11 +31,12 @@ public static HostedPageCheckoutExistingForItemsResponse fromJson(String json) { public static HostedPageCheckoutExistingForItemsResponse fromJson( String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __hostedPageJson = JsonUtil.getObject(json, "hosted_page"); - if (__hostedPageJson != null) { - builder.hostedPage(HostedPage.fromJson(__hostedPageJson)); + JsonObject __hostedPageObj = JsonUtil.getJsonObject(jsonObj, "hosted_page"); + if (__hostedPageObj != null) { + builder.hostedPage(HostedPage.fromJson(__hostedPageObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/hostedPage/responses/HostedPageCheckoutExistingResponse.java b/src/main/java/com/chargebee/v4/models/hostedPage/responses/HostedPageCheckoutExistingResponse.java index e7cb4bf2..64021e42 100644 --- a/src/main/java/com/chargebee/v4/models/hostedPage/responses/HostedPageCheckoutExistingResponse.java +++ b/src/main/java/com/chargebee/v4/models/hostedPage/responses/HostedPageCheckoutExistingResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static HostedPageCheckoutExistingResponse fromJson(String json) { /** Parse JSON response into HostedPageCheckoutExistingResponse object with HTTP response. */ public static HostedPageCheckoutExistingResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __hostedPageJson = JsonUtil.getObject(json, "hosted_page"); - if (__hostedPageJson != null) { - builder.hostedPage(HostedPage.fromJson(__hostedPageJson)); + JsonObject __hostedPageObj = JsonUtil.getJsonObject(jsonObj, "hosted_page"); + if (__hostedPageObj != null) { + builder.hostedPage(HostedPage.fromJson(__hostedPageObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/hostedPage/responses/HostedPageCheckoutGiftForItemsResponse.java b/src/main/java/com/chargebee/v4/models/hostedPage/responses/HostedPageCheckoutGiftForItemsResponse.java index d0ded732..68e51e8e 100644 --- a/src/main/java/com/chargebee/v4/models/hostedPage/responses/HostedPageCheckoutGiftForItemsResponse.java +++ b/src/main/java/com/chargebee/v4/models/hostedPage/responses/HostedPageCheckoutGiftForItemsResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -28,11 +29,12 @@ public static HostedPageCheckoutGiftForItemsResponse fromJson(String json) { public static HostedPageCheckoutGiftForItemsResponse fromJson( String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __hostedPageJson = JsonUtil.getObject(json, "hosted_page"); - if (__hostedPageJson != null) { - builder.hostedPage(HostedPage.fromJson(__hostedPageJson)); + JsonObject __hostedPageObj = JsonUtil.getJsonObject(jsonObj, "hosted_page"); + if (__hostedPageObj != null) { + builder.hostedPage(HostedPage.fromJson(__hostedPageObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/hostedPage/responses/HostedPageCheckoutGiftResponse.java b/src/main/java/com/chargebee/v4/models/hostedPage/responses/HostedPageCheckoutGiftResponse.java index 9b8b7ec8..99bc9a14 100644 --- a/src/main/java/com/chargebee/v4/models/hostedPage/responses/HostedPageCheckoutGiftResponse.java +++ b/src/main/java/com/chargebee/v4/models/hostedPage/responses/HostedPageCheckoutGiftResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static HostedPageCheckoutGiftResponse fromJson(String json) { /** Parse JSON response into HostedPageCheckoutGiftResponse object with HTTP response. */ public static HostedPageCheckoutGiftResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __hostedPageJson = JsonUtil.getObject(json, "hosted_page"); - if (__hostedPageJson != null) { - builder.hostedPage(HostedPage.fromJson(__hostedPageJson)); + JsonObject __hostedPageObj = JsonUtil.getJsonObject(jsonObj, "hosted_page"); + if (__hostedPageObj != null) { + builder.hostedPage(HostedPage.fromJson(__hostedPageObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/hostedPage/responses/HostedPageCheckoutNewForItemsResponse.java b/src/main/java/com/chargebee/v4/models/hostedPage/responses/HostedPageCheckoutNewForItemsResponse.java index 057896e1..aa930573 100644 --- a/src/main/java/com/chargebee/v4/models/hostedPage/responses/HostedPageCheckoutNewForItemsResponse.java +++ b/src/main/java/com/chargebee/v4/models/hostedPage/responses/HostedPageCheckoutNewForItemsResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static HostedPageCheckoutNewForItemsResponse fromJson(String json) { /** Parse JSON response into HostedPageCheckoutNewForItemsResponse object with HTTP response. */ public static HostedPageCheckoutNewForItemsResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __hostedPageJson = JsonUtil.getObject(json, "hosted_page"); - if (__hostedPageJson != null) { - builder.hostedPage(HostedPage.fromJson(__hostedPageJson)); + JsonObject __hostedPageObj = JsonUtil.getJsonObject(jsonObj, "hosted_page"); + if (__hostedPageObj != null) { + builder.hostedPage(HostedPage.fromJson(__hostedPageObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/hostedPage/responses/HostedPageCheckoutNewResponse.java b/src/main/java/com/chargebee/v4/models/hostedPage/responses/HostedPageCheckoutNewResponse.java index 942802e3..dda5ea4e 100644 --- a/src/main/java/com/chargebee/v4/models/hostedPage/responses/HostedPageCheckoutNewResponse.java +++ b/src/main/java/com/chargebee/v4/models/hostedPage/responses/HostedPageCheckoutNewResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static HostedPageCheckoutNewResponse fromJson(String json) { /** Parse JSON response into HostedPageCheckoutNewResponse object with HTTP response. */ public static HostedPageCheckoutNewResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __hostedPageJson = JsonUtil.getObject(json, "hosted_page"); - if (__hostedPageJson != null) { - builder.hostedPage(HostedPage.fromJson(__hostedPageJson)); + JsonObject __hostedPageObj = JsonUtil.getJsonObject(jsonObj, "hosted_page"); + if (__hostedPageObj != null) { + builder.hostedPage(HostedPage.fromJson(__hostedPageObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/hostedPage/responses/HostedPageCheckoutOneTimeForItemsResponse.java b/src/main/java/com/chargebee/v4/models/hostedPage/responses/HostedPageCheckoutOneTimeForItemsResponse.java index 45ff618e..0617c78e 100644 --- a/src/main/java/com/chargebee/v4/models/hostedPage/responses/HostedPageCheckoutOneTimeForItemsResponse.java +++ b/src/main/java/com/chargebee/v4/models/hostedPage/responses/HostedPageCheckoutOneTimeForItemsResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -30,11 +31,12 @@ public static HostedPageCheckoutOneTimeForItemsResponse fromJson(String json) { public static HostedPageCheckoutOneTimeForItemsResponse fromJson( String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __hostedPageJson = JsonUtil.getObject(json, "hosted_page"); - if (__hostedPageJson != null) { - builder.hostedPage(HostedPage.fromJson(__hostedPageJson)); + JsonObject __hostedPageObj = JsonUtil.getJsonObject(jsonObj, "hosted_page"); + if (__hostedPageObj != null) { + builder.hostedPage(HostedPage.fromJson(__hostedPageObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/hostedPage/responses/HostedPageCheckoutOneTimeResponse.java b/src/main/java/com/chargebee/v4/models/hostedPage/responses/HostedPageCheckoutOneTimeResponse.java index a7a332ac..bd7e72a4 100644 --- a/src/main/java/com/chargebee/v4/models/hostedPage/responses/HostedPageCheckoutOneTimeResponse.java +++ b/src/main/java/com/chargebee/v4/models/hostedPage/responses/HostedPageCheckoutOneTimeResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static HostedPageCheckoutOneTimeResponse fromJson(String json) { /** Parse JSON response into HostedPageCheckoutOneTimeResponse object with HTTP response. */ public static HostedPageCheckoutOneTimeResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __hostedPageJson = JsonUtil.getObject(json, "hosted_page"); - if (__hostedPageJson != null) { - builder.hostedPage(HostedPage.fromJson(__hostedPageJson)); + JsonObject __hostedPageObj = JsonUtil.getJsonObject(jsonObj, "hosted_page"); + if (__hostedPageObj != null) { + builder.hostedPage(HostedPage.fromJson(__hostedPageObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/hostedPage/responses/HostedPageClaimGiftResponse.java b/src/main/java/com/chargebee/v4/models/hostedPage/responses/HostedPageClaimGiftResponse.java index b2aeb809..507f86cf 100644 --- a/src/main/java/com/chargebee/v4/models/hostedPage/responses/HostedPageClaimGiftResponse.java +++ b/src/main/java/com/chargebee/v4/models/hostedPage/responses/HostedPageClaimGiftResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static HostedPageClaimGiftResponse fromJson(String json) { /** Parse JSON response into HostedPageClaimGiftResponse object with HTTP response. */ public static HostedPageClaimGiftResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __hostedPageJson = JsonUtil.getObject(json, "hosted_page"); - if (__hostedPageJson != null) { - builder.hostedPage(HostedPage.fromJson(__hostedPageJson)); + JsonObject __hostedPageObj = JsonUtil.getJsonObject(jsonObj, "hosted_page"); + if (__hostedPageObj != null) { + builder.hostedPage(HostedPage.fromJson(__hostedPageObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/hostedPage/responses/HostedPageCollectNowResponse.java b/src/main/java/com/chargebee/v4/models/hostedPage/responses/HostedPageCollectNowResponse.java index f34fa18c..876b5ef9 100644 --- a/src/main/java/com/chargebee/v4/models/hostedPage/responses/HostedPageCollectNowResponse.java +++ b/src/main/java/com/chargebee/v4/models/hostedPage/responses/HostedPageCollectNowResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static HostedPageCollectNowResponse fromJson(String json) { /** Parse JSON response into HostedPageCollectNowResponse object with HTTP response. */ public static HostedPageCollectNowResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __hostedPageJson = JsonUtil.getObject(json, "hosted_page"); - if (__hostedPageJson != null) { - builder.hostedPage(HostedPage.fromJson(__hostedPageJson)); + JsonObject __hostedPageObj = JsonUtil.getJsonObject(jsonObj, "hosted_page"); + if (__hostedPageObj != null) { + builder.hostedPage(HostedPage.fromJson(__hostedPageObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/hostedPage/responses/HostedPageEventsResponse.java b/src/main/java/com/chargebee/v4/models/hostedPage/responses/HostedPageEventsResponse.java index e4c9eb49..7dcdb97e 100644 --- a/src/main/java/com/chargebee/v4/models/hostedPage/responses/HostedPageEventsResponse.java +++ b/src/main/java/com/chargebee/v4/models/hostedPage/responses/HostedPageEventsResponse.java @@ -2,6 +2,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -25,9 +26,10 @@ public static HostedPageEventsResponse fromJson(String json) { /** Parse JSON response into HostedPageEventsResponse object with HTTP response. */ public static HostedPageEventsResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - builder.success(JsonUtil.getBoolean(json, "success")); + builder.success(JsonUtil.getBoolean(jsonObj, "success")); builder.httpResponse(httpResponse); return builder.build(); diff --git a/src/main/java/com/chargebee/v4/models/hostedPage/responses/HostedPageExtendSubscriptionResponse.java b/src/main/java/com/chargebee/v4/models/hostedPage/responses/HostedPageExtendSubscriptionResponse.java index 58a3138a..0f749429 100644 --- a/src/main/java/com/chargebee/v4/models/hostedPage/responses/HostedPageExtendSubscriptionResponse.java +++ b/src/main/java/com/chargebee/v4/models/hostedPage/responses/HostedPageExtendSubscriptionResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static HostedPageExtendSubscriptionResponse fromJson(String json) { /** Parse JSON response into HostedPageExtendSubscriptionResponse object with HTTP response. */ public static HostedPageExtendSubscriptionResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __hostedPageJson = JsonUtil.getObject(json, "hosted_page"); - if (__hostedPageJson != null) { - builder.hostedPage(HostedPage.fromJson(__hostedPageJson)); + JsonObject __hostedPageObj = JsonUtil.getJsonObject(jsonObj, "hosted_page"); + if (__hostedPageObj != null) { + builder.hostedPage(HostedPage.fromJson(__hostedPageObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/hostedPage/responses/HostedPageListResponse.java b/src/main/java/com/chargebee/v4/models/hostedPage/responses/HostedPageListResponse.java index ae5f512e..16ecaea8 100644 --- a/src/main/java/com/chargebee/v4/models/hostedPage/responses/HostedPageListResponse.java +++ b/src/main/java/com/chargebee/v4/models/hostedPage/responses/HostedPageListResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.exceptions.ChargebeeException; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; import com.chargebee.v4.services.HostedPageService; import com.chargebee.v4.models.hostedPage.params.HostedPageListParams; @@ -43,13 +44,12 @@ private HostedPageListResponse( */ public static HostedPageListResponse fromJson(String json) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(HostedPageListItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "list"), HostedPageListItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new HostedPageListResponse(list, nextOffset, null, null, null); } catch (Exception e) { @@ -67,13 +67,12 @@ public static HostedPageListResponse fromJson( HostedPageListParams originalParams, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(HostedPageListItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "list"), HostedPageListItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new HostedPageListResponse(list, nextOffset, service, originalParams, httpResponse); } catch (Exception e) { @@ -173,11 +172,15 @@ public HostedPage getHostedPage() { } public static HostedPageListItem fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static HostedPageListItem fromJson(JsonObject jsonObj) { HostedPageListItem item = new HostedPageListItem(); - String __hostedPageJson = JsonUtil.getObject(json, "hosted_page"); - if (__hostedPageJson != null) { - item.hostedPage = HostedPage.fromJson(__hostedPageJson); + JsonObject __hostedPageObj = JsonUtil.getJsonObject(jsonObj, "hosted_page"); + if (__hostedPageObj != null) { + item.hostedPage = HostedPage.fromJson(__hostedPageObj); } return item; diff --git a/src/main/java/com/chargebee/v4/models/hostedPage/responses/HostedPageManagePaymentSourcesResponse.java b/src/main/java/com/chargebee/v4/models/hostedPage/responses/HostedPageManagePaymentSourcesResponse.java index f139f1b1..12e5aeb5 100644 --- a/src/main/java/com/chargebee/v4/models/hostedPage/responses/HostedPageManagePaymentSourcesResponse.java +++ b/src/main/java/com/chargebee/v4/models/hostedPage/responses/HostedPageManagePaymentSourcesResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -28,11 +29,12 @@ public static HostedPageManagePaymentSourcesResponse fromJson(String json) { public static HostedPageManagePaymentSourcesResponse fromJson( String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __hostedPageJson = JsonUtil.getObject(json, "hosted_page"); - if (__hostedPageJson != null) { - builder.hostedPage(HostedPage.fromJson(__hostedPageJson)); + JsonObject __hostedPageObj = JsonUtil.getJsonObject(jsonObj, "hosted_page"); + if (__hostedPageObj != null) { + builder.hostedPage(HostedPage.fromJson(__hostedPageObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/hostedPage/responses/HostedPagePreCancelResponse.java b/src/main/java/com/chargebee/v4/models/hostedPage/responses/HostedPagePreCancelResponse.java index cf66924d..62d3041a 100644 --- a/src/main/java/com/chargebee/v4/models/hostedPage/responses/HostedPagePreCancelResponse.java +++ b/src/main/java/com/chargebee/v4/models/hostedPage/responses/HostedPagePreCancelResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static HostedPagePreCancelResponse fromJson(String json) { /** Parse JSON response into HostedPagePreCancelResponse object with HTTP response. */ public static HostedPagePreCancelResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __hostedPageJson = JsonUtil.getObject(json, "hosted_page"); - if (__hostedPageJson != null) { - builder.hostedPage(HostedPage.fromJson(__hostedPageJson)); + JsonObject __hostedPageObj = JsonUtil.getJsonObject(jsonObj, "hosted_page"); + if (__hostedPageObj != null) { + builder.hostedPage(HostedPage.fromJson(__hostedPageObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/hostedPage/responses/HostedPageRetrieveAgreementPdfResponse.java b/src/main/java/com/chargebee/v4/models/hostedPage/responses/HostedPageRetrieveAgreementPdfResponse.java index e18a95bd..15cd427a 100644 --- a/src/main/java/com/chargebee/v4/models/hostedPage/responses/HostedPageRetrieveAgreementPdfResponse.java +++ b/src/main/java/com/chargebee/v4/models/hostedPage/responses/HostedPageRetrieveAgreementPdfResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -28,11 +29,12 @@ public static HostedPageRetrieveAgreementPdfResponse fromJson(String json) { public static HostedPageRetrieveAgreementPdfResponse fromJson( String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __hostedPageJson = JsonUtil.getObject(json, "hosted_page"); - if (__hostedPageJson != null) { - builder.hostedPage(HostedPage.fromJson(__hostedPageJson)); + JsonObject __hostedPageObj = JsonUtil.getJsonObject(jsonObj, "hosted_page"); + if (__hostedPageObj != null) { + builder.hostedPage(HostedPage.fromJson(__hostedPageObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/hostedPage/responses/HostedPageRetrieveResponse.java b/src/main/java/com/chargebee/v4/models/hostedPage/responses/HostedPageRetrieveResponse.java index 5980de12..ba63f0fa 100644 --- a/src/main/java/com/chargebee/v4/models/hostedPage/responses/HostedPageRetrieveResponse.java +++ b/src/main/java/com/chargebee/v4/models/hostedPage/responses/HostedPageRetrieveResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static HostedPageRetrieveResponse fromJson(String json) { /** Parse JSON response into HostedPageRetrieveResponse object with HTTP response. */ public static HostedPageRetrieveResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __hostedPageJson = JsonUtil.getObject(json, "hosted_page"); - if (__hostedPageJson != null) { - builder.hostedPage(HostedPage.fromJson(__hostedPageJson)); + JsonObject __hostedPageObj = JsonUtil.getJsonObject(jsonObj, "hosted_page"); + if (__hostedPageObj != null) { + builder.hostedPage(HostedPage.fromJson(__hostedPageObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/hostedPage/responses/HostedPageUpdateCardResponse.java b/src/main/java/com/chargebee/v4/models/hostedPage/responses/HostedPageUpdateCardResponse.java index 626052b6..b53bd383 100644 --- a/src/main/java/com/chargebee/v4/models/hostedPage/responses/HostedPageUpdateCardResponse.java +++ b/src/main/java/com/chargebee/v4/models/hostedPage/responses/HostedPageUpdateCardResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static HostedPageUpdateCardResponse fromJson(String json) { /** Parse JSON response into HostedPageUpdateCardResponse object with HTTP response. */ public static HostedPageUpdateCardResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __hostedPageJson = JsonUtil.getObject(json, "hosted_page"); - if (__hostedPageJson != null) { - builder.hostedPage(HostedPage.fromJson(__hostedPageJson)); + JsonObject __hostedPageObj = JsonUtil.getJsonObject(jsonObj, "hosted_page"); + if (__hostedPageObj != null) { + builder.hostedPage(HostedPage.fromJson(__hostedPageObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/hostedPage/responses/HostedPageUpdatePaymentMethodResponse.java b/src/main/java/com/chargebee/v4/models/hostedPage/responses/HostedPageUpdatePaymentMethodResponse.java index b640deb8..b90bb683 100644 --- a/src/main/java/com/chargebee/v4/models/hostedPage/responses/HostedPageUpdatePaymentMethodResponse.java +++ b/src/main/java/com/chargebee/v4/models/hostedPage/responses/HostedPageUpdatePaymentMethodResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static HostedPageUpdatePaymentMethodResponse fromJson(String json) { /** Parse JSON response into HostedPageUpdatePaymentMethodResponse object with HTTP response. */ public static HostedPageUpdatePaymentMethodResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __hostedPageJson = JsonUtil.getObject(json, "hosted_page"); - if (__hostedPageJson != null) { - builder.hostedPage(HostedPage.fromJson(__hostedPageJson)); + JsonObject __hostedPageObj = JsonUtil.getJsonObject(jsonObj, "hosted_page"); + if (__hostedPageObj != null) { + builder.hostedPage(HostedPage.fromJson(__hostedPageObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/hostedPage/responses/HostedPageViewVoucherResponse.java b/src/main/java/com/chargebee/v4/models/hostedPage/responses/HostedPageViewVoucherResponse.java index f437764f..930d13dd 100644 --- a/src/main/java/com/chargebee/v4/models/hostedPage/responses/HostedPageViewVoucherResponse.java +++ b/src/main/java/com/chargebee/v4/models/hostedPage/responses/HostedPageViewVoucherResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static HostedPageViewVoucherResponse fromJson(String json) { /** Parse JSON response into HostedPageViewVoucherResponse object with HTTP response. */ public static HostedPageViewVoucherResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __hostedPageJson = JsonUtil.getObject(json, "hosted_page"); - if (__hostedPageJson != null) { - builder.hostedPage(HostedPage.fromJson(__hostedPageJson)); + JsonObject __hostedPageObj = JsonUtil.getJsonObject(jsonObj, "hosted_page"); + if (__hostedPageObj != null) { + builder.hostedPage(HostedPage.fromJson(__hostedPageObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/impactedCustomer/ImpactedCustomer.java b/src/main/java/com/chargebee/v4/models/impactedCustomer/ImpactedCustomer.java index 44647f25..b27ad42d 100644 --- a/src/main/java/com/chargebee/v4/models/impactedCustomer/ImpactedCustomer.java +++ b/src/main/java/com/chargebee/v4/models/impactedCustomer/ImpactedCustomer.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.impactedCustomer; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import java.sql.Timestamp; public class ImpactedCustomer { @@ -24,13 +25,17 @@ public Download getDownload() { } public static ImpactedCustomer fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static ImpactedCustomer fromJson(JsonObject jsonObj) { ImpactedCustomer obj = new ImpactedCustomer(); - obj.actionType = JsonUtil.getString(json, "action_type"); + obj.actionType = JsonUtil.getString(jsonObj, "action_type"); - String __downloadJson = JsonUtil.getObject(json, "download"); - if (__downloadJson != null) { - obj.download = Download.fromJson(__downloadJson); + JsonObject __downloadObj = JsonUtil.getJsonObject(jsonObj, "download"); + if (__downloadObj != null) { + obj.download = Download.fromJson(__downloadObj); } return obj; @@ -76,13 +81,17 @@ public String getMimeType() { } public static Download fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Download fromJson(JsonObject jsonObj) { Download obj = new Download(); - obj.downloadUrl = JsonUtil.getString(json, "download_url"); + obj.downloadUrl = JsonUtil.getString(jsonObj, "download_url"); - obj.validTill = JsonUtil.getTimestamp(json, "valid_till"); + obj.validTill = JsonUtil.getTimestamp(jsonObj, "valid_till"); - obj.mimeType = JsonUtil.getString(json, "mime_type"); + obj.mimeType = JsonUtil.getString(jsonObj, "mime_type"); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/impactedItem/ImpactedItem.java b/src/main/java/com/chargebee/v4/models/impactedItem/ImpactedItem.java index 9d96bf68..4eeb4dbf 100644 --- a/src/main/java/com/chargebee/v4/models/impactedItem/ImpactedItem.java +++ b/src/main/java/com/chargebee/v4/models/impactedItem/ImpactedItem.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.impactedItem; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import java.sql.Timestamp; import java.util.List; @@ -30,21 +31,19 @@ public Download getDownload() { } public static ImpactedItem fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static ImpactedItem fromJson(JsonObject jsonObj) { ImpactedItem obj = new ImpactedItem(); - obj.count = JsonUtil.getInteger(json, "count"); + obj.count = JsonUtil.getInteger(jsonObj, "count"); - String __itemsJson = JsonUtil.getArray(json, "items"); - obj.items = - __itemsJson != null - ? JsonUtil.parseObjectArray(__itemsJson).stream() - .map(JsonUtil::parseJsonObjectToMap) - .collect(java.util.stream.Collectors.toList()) - : null; + obj.items = JsonUtil.mapArrayToObjects(JsonUtil.getJsonArray(jsonObj, "items")); - String __downloadJson = JsonUtil.getObject(json, "download"); - if (__downloadJson != null) { - obj.download = Download.fromJson(__downloadJson); + JsonObject __downloadObj = JsonUtil.getJsonObject(jsonObj, "download"); + if (__downloadObj != null) { + obj.download = Download.fromJson(__downloadObj); } return obj; @@ -91,13 +90,17 @@ public String getMimeType() { } public static Download fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Download fromJson(JsonObject jsonObj) { Download obj = new Download(); - obj.downloadUrl = JsonUtil.getString(json, "download_url"); + obj.downloadUrl = JsonUtil.getString(jsonObj, "download_url"); - obj.validTill = JsonUtil.getTimestamp(json, "valid_till"); + obj.validTill = JsonUtil.getTimestamp(jsonObj, "valid_till"); - obj.mimeType = JsonUtil.getString(json, "mime_type"); + obj.mimeType = JsonUtil.getString(jsonObj, "mime_type"); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/impactedItemPrice/ImpactedItemPrice.java b/src/main/java/com/chargebee/v4/models/impactedItemPrice/ImpactedItemPrice.java index 17049fae..594c63c8 100644 --- a/src/main/java/com/chargebee/v4/models/impactedItemPrice/ImpactedItemPrice.java +++ b/src/main/java/com/chargebee/v4/models/impactedItemPrice/ImpactedItemPrice.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.impactedItemPrice; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import java.sql.Timestamp; import java.util.List; @@ -30,21 +31,19 @@ public Download getDownload() { } public static ImpactedItemPrice fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static ImpactedItemPrice fromJson(JsonObject jsonObj) { ImpactedItemPrice obj = new ImpactedItemPrice(); - obj.count = JsonUtil.getInteger(json, "count"); + obj.count = JsonUtil.getInteger(jsonObj, "count"); - String __itemPricesJson = JsonUtil.getArray(json, "item_prices"); - obj.itemPrices = - __itemPricesJson != null - ? JsonUtil.parseObjectArray(__itemPricesJson).stream() - .map(JsonUtil::parseJsonObjectToMap) - .collect(java.util.stream.Collectors.toList()) - : null; + obj.itemPrices = JsonUtil.mapArrayToObjects(JsonUtil.getJsonArray(jsonObj, "item_prices")); - String __downloadJson = JsonUtil.getObject(json, "download"); - if (__downloadJson != null) { - obj.download = Download.fromJson(__downloadJson); + JsonObject __downloadObj = JsonUtil.getJsonObject(jsonObj, "download"); + if (__downloadObj != null) { + obj.download = Download.fromJson(__downloadObj); } return obj; @@ -98,13 +97,17 @@ public String getMimeType() { } public static Download fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Download fromJson(JsonObject jsonObj) { Download obj = new Download(); - obj.downloadUrl = JsonUtil.getString(json, "download_url"); + obj.downloadUrl = JsonUtil.getString(jsonObj, "download_url"); - obj.validTill = JsonUtil.getTimestamp(json, "valid_till"); + obj.validTill = JsonUtil.getTimestamp(jsonObj, "valid_till"); - obj.mimeType = JsonUtil.getString(json, "mime_type"); + obj.mimeType = JsonUtil.getString(jsonObj, "mime_type"); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/impactedSubscription/ImpactedSubscription.java b/src/main/java/com/chargebee/v4/models/impactedSubscription/ImpactedSubscription.java index bdb09143..e7feea21 100644 --- a/src/main/java/com/chargebee/v4/models/impactedSubscription/ImpactedSubscription.java +++ b/src/main/java/com/chargebee/v4/models/impactedSubscription/ImpactedSubscription.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.impactedSubscription; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import java.sql.Timestamp; import java.util.List; @@ -30,21 +31,20 @@ public Download getDownload() { } public static ImpactedSubscription fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static ImpactedSubscription fromJson(JsonObject jsonObj) { ImpactedSubscription obj = new ImpactedSubscription(); - obj.count = JsonUtil.getInteger(json, "count"); + obj.count = JsonUtil.getInteger(jsonObj, "count"); - String __subscriptionIdsJson = JsonUtil.getArray(json, "subscription_ids"); obj.subscriptionIds = - __subscriptionIdsJson != null - ? JsonUtil.parseObjectArray(__subscriptionIdsJson).stream() - .map(JsonUtil::parseJsonObjectToMap) - .collect(java.util.stream.Collectors.toList()) - : null; - - String __downloadJson = JsonUtil.getObject(json, "download"); - if (__downloadJson != null) { - obj.download = Download.fromJson(__downloadJson); + JsonUtil.mapArrayToObjects(JsonUtil.getJsonArray(jsonObj, "subscription_ids")); + + JsonObject __downloadObj = JsonUtil.getJsonObject(jsonObj, "download"); + if (__downloadObj != null) { + obj.download = Download.fromJson(__downloadObj); } return obj; @@ -98,13 +98,17 @@ public String getMimeType() { } public static Download fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Download fromJson(JsonObject jsonObj) { Download obj = new Download(); - obj.downloadUrl = JsonUtil.getString(json, "download_url"); + obj.downloadUrl = JsonUtil.getString(jsonObj, "download_url"); - obj.validTill = JsonUtil.getTimestamp(json, "valid_till"); + obj.validTill = JsonUtil.getTimestamp(jsonObj, "valid_till"); - obj.mimeType = JsonUtil.getString(json, "mime_type"); + obj.mimeType = JsonUtil.getString(jsonObj, "mime_type"); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/inAppSubscription/InAppSubscription.java b/src/main/java/com/chargebee/v4/models/inAppSubscription/InAppSubscription.java index bf63d6f3..e733633f 100644 --- a/src/main/java/com/chargebee/v4/models/inAppSubscription/InAppSubscription.java +++ b/src/main/java/com/chargebee/v4/models/inAppSubscription/InAppSubscription.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.inAppSubscription; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; public class InAppSubscription { @@ -76,19 +77,23 @@ public static StoreStatus fromString(String value) { } public static InAppSubscription fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static InAppSubscription fromJson(JsonObject jsonObj) { InAppSubscription obj = new InAppSubscription(); - obj.appId = JsonUtil.getString(json, "app_id"); + obj.appId = JsonUtil.getString(jsonObj, "app_id"); - obj.subscriptionId = JsonUtil.getString(json, "subscription_id"); + obj.subscriptionId = JsonUtil.getString(jsonObj, "subscription_id"); - obj.customerId = JsonUtil.getString(json, "customer_id"); + obj.customerId = JsonUtil.getString(jsonObj, "customer_id"); - obj.planId = JsonUtil.getString(json, "plan_id"); + obj.planId = JsonUtil.getString(jsonObj, "plan_id"); - obj.storeStatus = StoreStatus.fromString(JsonUtil.getString(json, "store_status")); + obj.storeStatus = StoreStatus.fromString(JsonUtil.getString(jsonObj, "store_status")); - obj.invoiceId = JsonUtil.getString(json, "invoice_id"); + obj.invoiceId = JsonUtil.getString(jsonObj, "invoice_id"); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/inAppSubscription/responses/InAppSubscriptionImportReceiptResponse.java b/src/main/java/com/chargebee/v4/models/inAppSubscription/responses/InAppSubscriptionImportReceiptResponse.java index 144ea9fe..abc4f3da 100644 --- a/src/main/java/com/chargebee/v4/models/inAppSubscription/responses/InAppSubscriptionImportReceiptResponse.java +++ b/src/main/java/com/chargebee/v4/models/inAppSubscription/responses/InAppSubscriptionImportReceiptResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -30,12 +31,12 @@ public static InAppSubscriptionImportReceiptResponse fromJson(String json) { public static InAppSubscriptionImportReceiptResponse fromJson( String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); builder.inAppSubscriptions( - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "in_app_subscriptions")).stream() - .map(InAppSubscription::fromJson) - .collect(java.util.stream.Collectors.toList())); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "in_app_subscriptions"), InAppSubscription::fromJson)); builder.httpResponse(httpResponse); return builder.build(); diff --git a/src/main/java/com/chargebee/v4/models/inAppSubscription/responses/InAppSubscriptionImportSubscriptionResponse.java b/src/main/java/com/chargebee/v4/models/inAppSubscription/responses/InAppSubscriptionImportSubscriptionResponse.java index 56f3bbdd..c40b41dd 100644 --- a/src/main/java/com/chargebee/v4/models/inAppSubscription/responses/InAppSubscriptionImportSubscriptionResponse.java +++ b/src/main/java/com/chargebee/v4/models/inAppSubscription/responses/InAppSubscriptionImportSubscriptionResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -30,11 +31,12 @@ public static InAppSubscriptionImportSubscriptionResponse fromJson(String json) public static InAppSubscriptionImportSubscriptionResponse fromJson( String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __inAppSubscriptionJson = JsonUtil.getObject(json, "in_app_subscription"); - if (__inAppSubscriptionJson != null) { - builder.inAppSubscription(InAppSubscription.fromJson(__inAppSubscriptionJson)); + JsonObject __inAppSubscriptionObj = JsonUtil.getJsonObject(jsonObj, "in_app_subscription"); + if (__inAppSubscriptionObj != null) { + builder.inAppSubscription(InAppSubscription.fromJson(__inAppSubscriptionObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/inAppSubscription/responses/InAppSubscriptionProcessReceiptResponse.java b/src/main/java/com/chargebee/v4/models/inAppSubscription/responses/InAppSubscriptionProcessReceiptResponse.java index 1005a319..19e21981 100644 --- a/src/main/java/com/chargebee/v4/models/inAppSubscription/responses/InAppSubscriptionProcessReceiptResponse.java +++ b/src/main/java/com/chargebee/v4/models/inAppSubscription/responses/InAppSubscriptionProcessReceiptResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -28,11 +29,12 @@ public static InAppSubscriptionProcessReceiptResponse fromJson(String json) { public static InAppSubscriptionProcessReceiptResponse fromJson( String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __inAppSubscriptionJson = JsonUtil.getObject(json, "in_app_subscription"); - if (__inAppSubscriptionJson != null) { - builder.inAppSubscription(InAppSubscription.fromJson(__inAppSubscriptionJson)); + JsonObject __inAppSubscriptionObj = JsonUtil.getJsonObject(jsonObj, "in_app_subscription"); + if (__inAppSubscriptionObj != null) { + builder.inAppSubscription(InAppSubscription.fromJson(__inAppSubscriptionObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/inAppSubscription/responses/InAppSubscriptionRetrieveStoreSubscriptionsResponse.java b/src/main/java/com/chargebee/v4/models/inAppSubscription/responses/InAppSubscriptionRetrieveStoreSubscriptionsResponse.java index dc149ba2..3a2cb4c6 100644 --- a/src/main/java/com/chargebee/v4/models/inAppSubscription/responses/InAppSubscriptionRetrieveStoreSubscriptionsResponse.java +++ b/src/main/java/com/chargebee/v4/models/inAppSubscription/responses/InAppSubscriptionRetrieveStoreSubscriptionsResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -33,12 +34,12 @@ public static InAppSubscriptionRetrieveStoreSubscriptionsResponse fromJson(Strin public static InAppSubscriptionRetrieveStoreSubscriptionsResponse fromJson( String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); builder.inAppSubscriptions( - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "in_app_subscriptions")).stream() - .map(InAppSubscription::fromJson) - .collect(java.util.stream.Collectors.toList())); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "in_app_subscriptions"), InAppSubscription::fromJson)); builder.httpResponse(httpResponse); return builder.build(); diff --git a/src/main/java/com/chargebee/v4/models/invoice/Invoice.java b/src/main/java/com/chargebee/v4/models/invoice/Invoice.java index 580e5e7d..188c9481 100644 --- a/src/main/java/com/chargebee/v4/models/invoice/Invoice.java +++ b/src/main/java/com/chargebee/v4/models/invoice/Invoice.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.invoice; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import java.math.BigDecimal; import java.sql.Timestamp; import java.util.List; @@ -514,9 +515,12 @@ public static Channel fromString(String value) { } public static Invoice fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Invoice fromJson(JsonObject jsonObj) { Invoice obj = new Invoice(); - // Parse JSON to extract all keys for custom field extraction java.util.Set knownFields = new java.util.HashSet<>(); knownFields.add("id"); @@ -659,248 +663,197 @@ public static Invoice fromJson(String json) { knownFields.add("site_details_at_creation"); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.customerId = JsonUtil.getString(json, "customer_id"); + obj.customerId = JsonUtil.getString(jsonObj, "customer_id"); - obj.paymentOwner = JsonUtil.getString(json, "payment_owner"); + obj.paymentOwner = JsonUtil.getString(jsonObj, "payment_owner"); - obj.subscriptionId = JsonUtil.getString(json, "subscription_id"); + obj.subscriptionId = JsonUtil.getString(jsonObj, "subscription_id"); - obj.recurring = JsonUtil.getBoolean(json, "recurring"); + obj.recurring = JsonUtil.getBoolean(jsonObj, "recurring"); - obj.status = Status.fromString(JsonUtil.getString(json, "status")); + obj.status = Status.fromString(JsonUtil.getString(jsonObj, "status")); - obj.date = JsonUtil.getTimestamp(json, "date"); + obj.date = JsonUtil.getTimestamp(jsonObj, "date"); - obj.dueDate = JsonUtil.getTimestamp(json, "due_date"); + obj.dueDate = JsonUtil.getTimestamp(jsonObj, "due_date"); - obj.netTermDays = JsonUtil.getInteger(json, "net_term_days"); + obj.netTermDays = JsonUtil.getInteger(jsonObj, "net_term_days"); - obj.poNumber = JsonUtil.getString(json, "po_number"); + obj.poNumber = JsonUtil.getString(jsonObj, "po_number"); - obj.vatNumber = JsonUtil.getString(json, "vat_number"); + obj.vatNumber = JsonUtil.getString(jsonObj, "vat_number"); - obj.priceType = PriceType.fromString(JsonUtil.getString(json, "price_type")); + obj.priceType = PriceType.fromString(JsonUtil.getString(jsonObj, "price_type")); - obj.exchangeRate = JsonUtil.getBigDecimal(json, "exchange_rate"); + obj.exchangeRate = JsonUtil.getBigDecimal(jsonObj, "exchange_rate"); - obj.localCurrencyExchangeRate = JsonUtil.getBigDecimal(json, "local_currency_exchange_rate"); + obj.localCurrencyExchangeRate = JsonUtil.getBigDecimal(jsonObj, "local_currency_exchange_rate"); - obj.currencyCode = JsonUtil.getString(json, "currency_code"); + obj.currencyCode = JsonUtil.getString(jsonObj, "currency_code"); - obj.localCurrencyCode = JsonUtil.getString(json, "local_currency_code"); + obj.localCurrencyCode = JsonUtil.getString(jsonObj, "local_currency_code"); - obj.tax = JsonUtil.getLong(json, "tax"); + obj.tax = JsonUtil.getLong(jsonObj, "tax"); - obj.subTotal = JsonUtil.getLong(json, "sub_total"); + obj.subTotal = JsonUtil.getLong(jsonObj, "sub_total"); - obj.subTotalInLocalCurrency = JsonUtil.getLong(json, "sub_total_in_local_currency"); + obj.subTotalInLocalCurrency = JsonUtil.getLong(jsonObj, "sub_total_in_local_currency"); - obj.total = JsonUtil.getLong(json, "total"); + obj.total = JsonUtil.getLong(jsonObj, "total"); - obj.totalInLocalCurrency = JsonUtil.getLong(json, "total_in_local_currency"); + obj.totalInLocalCurrency = JsonUtil.getLong(jsonObj, "total_in_local_currency"); - obj.amountDue = JsonUtil.getLong(json, "amount_due"); + obj.amountDue = JsonUtil.getLong(jsonObj, "amount_due"); - obj.amountAdjusted = JsonUtil.getLong(json, "amount_adjusted"); + obj.amountAdjusted = JsonUtil.getLong(jsonObj, "amount_adjusted"); - obj.amountPaid = JsonUtil.getLong(json, "amount_paid"); + obj.amountPaid = JsonUtil.getLong(jsonObj, "amount_paid"); - obj.paidAt = JsonUtil.getTimestamp(json, "paid_at"); + obj.paidAt = JsonUtil.getTimestamp(jsonObj, "paid_at"); - obj.writeOffAmount = JsonUtil.getLong(json, "write_off_amount"); + obj.writeOffAmount = JsonUtil.getLong(jsonObj, "write_off_amount"); - obj.creditsApplied = JsonUtil.getLong(json, "credits_applied"); + obj.creditsApplied = JsonUtil.getLong(jsonObj, "credits_applied"); - obj.dunningStatus = DunningStatus.fromString(JsonUtil.getString(json, "dunning_status")); + obj.dunningStatus = DunningStatus.fromString(JsonUtil.getString(jsonObj, "dunning_status")); - obj.nextRetryAt = JsonUtil.getTimestamp(json, "next_retry_at"); + obj.nextRetryAt = JsonUtil.getTimestamp(jsonObj, "next_retry_at"); - obj.voidedAt = JsonUtil.getTimestamp(json, "voided_at"); + obj.voidedAt = JsonUtil.getTimestamp(jsonObj, "voided_at"); - obj.resourceVersion = JsonUtil.getLong(json, "resource_version"); + obj.resourceVersion = JsonUtil.getLong(jsonObj, "resource_version"); - obj.updatedAt = JsonUtil.getTimestamp(json, "updated_at"); + obj.updatedAt = JsonUtil.getTimestamp(jsonObj, "updated_at"); - obj.lineItemsNextOffset = JsonUtil.getString(json, "line_items_next_offset"); + obj.lineItemsNextOffset = JsonUtil.getString(jsonObj, "line_items_next_offset"); - obj.firstInvoice = JsonUtil.getBoolean(json, "first_invoice"); + obj.firstInvoice = JsonUtil.getBoolean(jsonObj, "first_invoice"); - obj.newSalesAmount = JsonUtil.getLong(json, "new_sales_amount"); + obj.newSalesAmount = JsonUtil.getLong(jsonObj, "new_sales_amount"); - obj.hasAdvanceCharges = JsonUtil.getBoolean(json, "has_advance_charges"); + obj.hasAdvanceCharges = JsonUtil.getBoolean(jsonObj, "has_advance_charges"); - obj.termFinalized = JsonUtil.getBoolean(json, "term_finalized"); + obj.termFinalized = JsonUtil.getBoolean(jsonObj, "term_finalized"); - obj.isGifted = JsonUtil.getBoolean(json, "is_gifted"); + obj.isGifted = JsonUtil.getBoolean(jsonObj, "is_gifted"); - obj.generatedAt = JsonUtil.getTimestamp(json, "generated_at"); + obj.generatedAt = JsonUtil.getTimestamp(jsonObj, "generated_at"); - obj.expectedPaymentDate = JsonUtil.getTimestamp(json, "expected_payment_date"); + obj.expectedPaymentDate = JsonUtil.getTimestamp(jsonObj, "expected_payment_date"); - obj.amountToCollect = JsonUtil.getLong(json, "amount_to_collect"); + obj.amountToCollect = JsonUtil.getLong(jsonObj, "amount_to_collect"); - obj.roundOffAmount = JsonUtil.getLong(json, "round_off_amount"); + obj.roundOffAmount = JsonUtil.getLong(jsonObj, "round_off_amount"); - obj.voidReasonCode = JsonUtil.getString(json, "void_reason_code"); + obj.voidReasonCode = JsonUtil.getString(jsonObj, "void_reason_code"); - obj.deleted = JsonUtil.getBoolean(json, "deleted"); + obj.deleted = JsonUtil.getBoolean(jsonObj, "deleted"); - obj.taxCategory = JsonUtil.getString(json, "tax_category"); + obj.taxCategory = JsonUtil.getString(jsonObj, "tax_category"); - obj.vatNumberPrefix = JsonUtil.getString(json, "vat_number_prefix"); + obj.vatNumberPrefix = JsonUtil.getString(jsonObj, "vat_number_prefix"); - obj.channel = Channel.fromString(JsonUtil.getString(json, "channel")); + obj.channel = Channel.fromString(JsonUtil.getString(jsonObj, "channel")); - obj.businessEntityId = JsonUtil.getString(json, "business_entity_id"); + obj.businessEntityId = JsonUtil.getString(jsonObj, "business_entity_id"); obj.lineItems = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "line_items")).stream() - .map(LineItems::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "line_items"), LineItems::fromJson); obj.lineItemTiers = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "line_item_tiers")).stream() - .map(LineItemTiers::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "line_item_tiers"), LineItemTiers::fromJson); obj.lineItemDiscounts = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "line_item_discounts")).stream() - .map(LineItemDiscounts::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "line_item_discounts"), LineItemDiscounts::fromJson); obj.lineItemTaxes = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "line_item_taxes")).stream() - .map(LineItemTaxes::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "line_item_taxes"), LineItemTaxes::fromJson); obj.lineItemCredits = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "line_item_credits")).stream() - .map(LineItemCredits::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "line_item_credits"), LineItemCredits::fromJson); obj.lineItemAddresses = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "line_item_addresses")).stream() - .map(LineItemAddresses::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "line_item_addresses"), LineItemAddresses::fromJson); obj.discounts = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "discounts")).stream() - .map(Discounts::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "discounts"), Discounts::fromJson); - obj.taxes = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "taxes")).stream() - .map(Taxes::fromJson) - .collect(java.util.stream.Collectors.toList()); + obj.taxes = JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "taxes"), Taxes::fromJson); - String __taxOriginJson = JsonUtil.getObject(json, "tax_origin"); - if (__taxOriginJson != null) { - obj.taxOrigin = TaxOrigin.fromJson(__taxOriginJson); + JsonObject __taxOriginObj = JsonUtil.getJsonObject(jsonObj, "tax_origin"); + if (__taxOriginObj != null) { + obj.taxOrigin = TaxOrigin.fromJson(__taxOriginObj); } obj.linkedPayments = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "linked_payments")).stream() - .map(LinkedPayments::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "linked_payments"), LinkedPayments::fromJson); obj.referenceTransactions = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "reference_transactions")).stream() - .map(ReferenceTransactions::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "reference_transactions"), + ReferenceTransactions::fromJson); obj.dunningAttempts = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "dunning_attempts")).stream() - .map(DunningAttempts::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "dunning_attempts"), DunningAttempts::fromJson); obj.appliedCredits = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "applied_credits")).stream() - .map(AppliedCredits::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "applied_credits"), AppliedCredits::fromJson); obj.adjustmentCreditNotes = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "adjustment_credit_notes")).stream() - .map(AdjustmentCreditNotes::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "adjustment_credit_notes"), + AdjustmentCreditNotes::fromJson); obj.issuedCreditNotes = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "issued_credit_notes")).stream() - .map(IssuedCreditNotes::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "issued_credit_notes"), IssuedCreditNotes::fromJson); obj.linkedOrders = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "linked_orders")).stream() - .map(LinkedOrders::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "linked_orders"), LinkedOrders::fromJson); - obj.notes = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "notes")).stream() - .map(Notes::fromJson) - .collect(java.util.stream.Collectors.toList()); + obj.notes = JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "notes"), Notes::fromJson); - String __shippingAddressJson = JsonUtil.getObject(json, "shipping_address"); - if (__shippingAddressJson != null) { - obj.shippingAddress = ShippingAddress.fromJson(__shippingAddressJson); + JsonObject __shippingAddressObj = JsonUtil.getJsonObject(jsonObj, "shipping_address"); + if (__shippingAddressObj != null) { + obj.shippingAddress = ShippingAddress.fromJson(__shippingAddressObj); } - String __billingAddressJson = JsonUtil.getObject(json, "billing_address"); - if (__billingAddressJson != null) { - obj.billingAddress = BillingAddress.fromJson(__billingAddressJson); + JsonObject __billingAddressObj = JsonUtil.getJsonObject(jsonObj, "billing_address"); + if (__billingAddressObj != null) { + obj.billingAddress = BillingAddress.fromJson(__billingAddressObj); } - String __statementDescriptorJson = JsonUtil.getObject(json, "statement_descriptor"); - if (__statementDescriptorJson != null) { - obj.statementDescriptor = StatementDescriptor.fromJson(__statementDescriptorJson); + JsonObject __statementDescriptorObj = JsonUtil.getJsonObject(jsonObj, "statement_descriptor"); + if (__statementDescriptorObj != null) { + obj.statementDescriptor = StatementDescriptor.fromJson(__statementDescriptorObj); } - String __einvoiceJson = JsonUtil.getObject(json, "einvoice"); - if (__einvoiceJson != null) { - obj.einvoice = Einvoice.fromJson(__einvoiceJson); + JsonObject __einvoiceObj = JsonUtil.getJsonObject(jsonObj, "einvoice"); + if (__einvoiceObj != null) { + obj.einvoice = Einvoice.fromJson(__einvoiceObj); } - String __siteDetailsAtCreationJson = JsonUtil.getObject(json, "site_details_at_creation"); - if (__siteDetailsAtCreationJson != null) { - obj.siteDetailsAtCreation = SiteDetailsAtCreation.fromJson(__siteDetailsAtCreationJson); + JsonObject __siteDetailsAtCreationObj = + JsonUtil.getJsonObject(jsonObj, "site_details_at_creation"); + if (__siteDetailsAtCreationObj != null) { + obj.siteDetailsAtCreation = SiteDetailsAtCreation.fromJson(__siteDetailsAtCreationObj); } - // Extract custom fields (fields starting with cf_) - obj.customFields = extractCustomFields(json, knownFields); + obj.customFields = JsonUtil.extractCustomFields(jsonObj, knownFields); return obj; } - /** - * Helper method to extract custom fields from JSON. Custom fields are fields that start with - * "cf_" and are not in the known fields set. - * - * @param json JSON string to parse - * @param knownFields set of known field names - * @return map of custom fields - */ - private static java.util.Map extractCustomFields( - String json, java.util.Set knownFields) { - java.util.Map customFields = new java.util.HashMap<>(); - try { - // Parse the entire JSON as a map - java.util.Map allFields = JsonUtil.parseJsonObjectToMap(json); - if (allFields != null) { - for (java.util.Map.Entry entry : allFields.entrySet()) { - String key = entry.getKey(); - // Include fields that start with "cf_" and are not in knownFields - if (key != null && key.startsWith("cf_") && !knownFields.contains(key)) { - customFields.put( - key, entry.getValue() != null ? String.valueOf(entry.getValue()) : null); - } - } - } - } catch (Exception e) { - // If parsing fails, return empty map - } - return customFields; - } - @Override public String toString() { return "Invoice{" @@ -1450,58 +1403,62 @@ public static TaxExemptReason fromString(String value) { } public static LineItems fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static LineItems fromJson(JsonObject jsonObj) { LineItems obj = new LineItems(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.subscriptionId = JsonUtil.getString(json, "subscription_id"); + obj.subscriptionId = JsonUtil.getString(jsonObj, "subscription_id"); - obj.dateFrom = JsonUtil.getTimestamp(json, "date_from"); + obj.dateFrom = JsonUtil.getTimestamp(jsonObj, "date_from"); - obj.dateTo = JsonUtil.getTimestamp(json, "date_to"); + obj.dateTo = JsonUtil.getTimestamp(jsonObj, "date_to"); - obj.unitAmount = JsonUtil.getLong(json, "unit_amount"); + obj.unitAmount = JsonUtil.getLong(jsonObj, "unit_amount"); - obj.quantity = JsonUtil.getInteger(json, "quantity"); + obj.quantity = JsonUtil.getInteger(jsonObj, "quantity"); - obj.amount = JsonUtil.getLong(json, "amount"); + obj.amount = JsonUtil.getLong(jsonObj, "amount"); - obj.pricingModel = PricingModel.fromString(JsonUtil.getString(json, "pricing_model")); + obj.pricingModel = PricingModel.fromString(JsonUtil.getString(jsonObj, "pricing_model")); - obj.isTaxed = JsonUtil.getBoolean(json, "is_taxed"); + obj.isTaxed = JsonUtil.getBoolean(jsonObj, "is_taxed"); - obj.taxAmount = JsonUtil.getLong(json, "tax_amount"); + obj.taxAmount = JsonUtil.getLong(jsonObj, "tax_amount"); - obj.taxRate = JsonUtil.getDouble(json, "tax_rate"); + obj.taxRate = JsonUtil.getDouble(jsonObj, "tax_rate"); - obj.unitAmountInDecimal = JsonUtil.getString(json, "unit_amount_in_decimal"); + obj.unitAmountInDecimal = JsonUtil.getString(jsonObj, "unit_amount_in_decimal"); - obj.quantityInDecimal = JsonUtil.getString(json, "quantity_in_decimal"); + obj.quantityInDecimal = JsonUtil.getString(jsonObj, "quantity_in_decimal"); - obj.amountInDecimal = JsonUtil.getString(json, "amount_in_decimal"); + obj.amountInDecimal = JsonUtil.getString(jsonObj, "amount_in_decimal"); - obj.discountAmount = JsonUtil.getLong(json, "discount_amount"); + obj.discountAmount = JsonUtil.getLong(jsonObj, "discount_amount"); - obj.itemLevelDiscountAmount = JsonUtil.getLong(json, "item_level_discount_amount"); + obj.itemLevelDiscountAmount = JsonUtil.getLong(jsonObj, "item_level_discount_amount"); - obj.metered = JsonUtil.getBoolean(json, "metered"); + obj.metered = JsonUtil.getBoolean(jsonObj, "metered"); - obj.isPercentagePricing = JsonUtil.getBoolean(json, "is_percentage_pricing"); + obj.isPercentagePricing = JsonUtil.getBoolean(jsonObj, "is_percentage_pricing"); - obj.referenceLineItemId = JsonUtil.getString(json, "reference_line_item_id"); + obj.referenceLineItemId = JsonUtil.getString(jsonObj, "reference_line_item_id"); - obj.description = JsonUtil.getString(json, "description"); + obj.description = JsonUtil.getString(jsonObj, "description"); - obj.entityDescription = JsonUtil.getString(json, "entity_description"); + obj.entityDescription = JsonUtil.getString(jsonObj, "entity_description"); - obj.entityType = EntityType.fromString(JsonUtil.getString(json, "entity_type")); + obj.entityType = EntityType.fromString(JsonUtil.getString(jsonObj, "entity_type")); obj.taxExemptReason = - TaxExemptReason.fromString(JsonUtil.getString(json, "tax_exempt_reason")); + TaxExemptReason.fromString(JsonUtil.getString(jsonObj, "tax_exempt_reason")); - obj.entityId = JsonUtil.getString(json, "entity_id"); + obj.entityId = JsonUtil.getString(jsonObj, "entity_id"); - obj.customerId = JsonUtil.getString(json, "customer_id"); + obj.customerId = JsonUtil.getString(jsonObj, "customer_id"); return obj; } @@ -1716,29 +1673,33 @@ public static PricingType fromString(String value) { } public static LineItemTiers fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static LineItemTiers fromJson(JsonObject jsonObj) { LineItemTiers obj = new LineItemTiers(); - obj.lineItemId = JsonUtil.getString(json, "line_item_id"); + obj.lineItemId = JsonUtil.getString(jsonObj, "line_item_id"); - obj.startingUnit = JsonUtil.getInteger(json, "starting_unit"); + obj.startingUnit = JsonUtil.getInteger(jsonObj, "starting_unit"); - obj.endingUnit = JsonUtil.getInteger(json, "ending_unit"); + obj.endingUnit = JsonUtil.getInteger(jsonObj, "ending_unit"); - obj.quantityUsed = JsonUtil.getInteger(json, "quantity_used"); + obj.quantityUsed = JsonUtil.getInteger(jsonObj, "quantity_used"); - obj.unitAmount = JsonUtil.getLong(json, "unit_amount"); + obj.unitAmount = JsonUtil.getLong(jsonObj, "unit_amount"); - obj.startingUnitInDecimal = JsonUtil.getString(json, "starting_unit_in_decimal"); + obj.startingUnitInDecimal = JsonUtil.getString(jsonObj, "starting_unit_in_decimal"); - obj.endingUnitInDecimal = JsonUtil.getString(json, "ending_unit_in_decimal"); + obj.endingUnitInDecimal = JsonUtil.getString(jsonObj, "ending_unit_in_decimal"); - obj.quantityUsedInDecimal = JsonUtil.getString(json, "quantity_used_in_decimal"); + obj.quantityUsedInDecimal = JsonUtil.getString(jsonObj, "quantity_used_in_decimal"); - obj.unitAmountInDecimal = JsonUtil.getString(json, "unit_amount_in_decimal"); + obj.unitAmountInDecimal = JsonUtil.getString(jsonObj, "unit_amount_in_decimal"); - obj.pricingType = PricingType.fromString(JsonUtil.getString(json, "pricing_type")); + obj.pricingType = PricingType.fromString(JsonUtil.getString(jsonObj, "pricing_type")); - obj.packageSize = JsonUtil.getInteger(json, "package_size"); + obj.packageSize = JsonUtil.getInteger(jsonObj, "package_size"); return obj; } @@ -1873,17 +1834,21 @@ public static DiscountType fromString(String value) { } public static LineItemDiscounts fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static LineItemDiscounts fromJson(JsonObject jsonObj) { LineItemDiscounts obj = new LineItemDiscounts(); - obj.lineItemId = JsonUtil.getString(json, "line_item_id"); + obj.lineItemId = JsonUtil.getString(jsonObj, "line_item_id"); - obj.discountType = DiscountType.fromString(JsonUtil.getString(json, "discount_type")); + obj.discountType = DiscountType.fromString(JsonUtil.getString(jsonObj, "discount_type")); - obj.couponId = JsonUtil.getString(json, "coupon_id"); + obj.couponId = JsonUtil.getString(jsonObj, "coupon_id"); - obj.entityId = JsonUtil.getString(json, "entity_id"); + obj.entityId = JsonUtil.getString(jsonObj, "entity_id"); - obj.discountAmount = JsonUtil.getLong(json, "discount_amount"); + obj.discountAmount = JsonUtil.getLong(jsonObj, "discount_amount"); return obj; } @@ -2043,37 +2008,41 @@ public static TaxJurisType fromString(String value) { } public static LineItemTaxes fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static LineItemTaxes fromJson(JsonObject jsonObj) { LineItemTaxes obj = new LineItemTaxes(); - obj.lineItemId = JsonUtil.getString(json, "line_item_id"); + obj.lineItemId = JsonUtil.getString(jsonObj, "line_item_id"); - obj.taxName = JsonUtil.getString(json, "tax_name"); + obj.taxName = JsonUtil.getString(jsonObj, "tax_name"); - obj.taxRate = JsonUtil.getDouble(json, "tax_rate"); + obj.taxRate = JsonUtil.getDouble(jsonObj, "tax_rate"); - obj.dateTo = JsonUtil.getTimestamp(json, "date_to"); + obj.dateTo = JsonUtil.getTimestamp(jsonObj, "date_to"); - obj.dateFrom = JsonUtil.getTimestamp(json, "date_from"); + obj.dateFrom = JsonUtil.getTimestamp(jsonObj, "date_from"); - obj.proratedTaxableAmount = JsonUtil.getBigDecimal(json, "prorated_taxable_amount"); + obj.proratedTaxableAmount = JsonUtil.getBigDecimal(jsonObj, "prorated_taxable_amount"); - obj.isPartialTaxApplied = JsonUtil.getBoolean(json, "is_partial_tax_applied"); + obj.isPartialTaxApplied = JsonUtil.getBoolean(jsonObj, "is_partial_tax_applied"); - obj.isNonComplianceTax = JsonUtil.getBoolean(json, "is_non_compliance_tax"); + obj.isNonComplianceTax = JsonUtil.getBoolean(jsonObj, "is_non_compliance_tax"); - obj.taxableAmount = JsonUtil.getLong(json, "taxable_amount"); + obj.taxableAmount = JsonUtil.getLong(jsonObj, "taxable_amount"); - obj.taxAmount = JsonUtil.getLong(json, "tax_amount"); + obj.taxAmount = JsonUtil.getLong(jsonObj, "tax_amount"); - obj.taxJurisType = TaxJurisType.fromString(JsonUtil.getString(json, "tax_juris_type")); + obj.taxJurisType = TaxJurisType.fromString(JsonUtil.getString(jsonObj, "tax_juris_type")); - obj.taxJurisName = JsonUtil.getString(json, "tax_juris_name"); + obj.taxJurisName = JsonUtil.getString(jsonObj, "tax_juris_name"); - obj.taxJurisCode = JsonUtil.getString(json, "tax_juris_code"); + obj.taxJurisCode = JsonUtil.getString(jsonObj, "tax_juris_code"); - obj.taxAmountInLocalCurrency = JsonUtil.getLong(json, "tax_amount_in_local_currency"); + obj.taxAmountInLocalCurrency = JsonUtil.getLong(jsonObj, "tax_amount_in_local_currency"); - obj.localCurrencyCode = JsonUtil.getString(json, "local_currency_code"); + obj.localCurrencyCode = JsonUtil.getString(jsonObj, "local_currency_code"); return obj; } @@ -2178,13 +2147,17 @@ public String getLineItemId() { } public static LineItemCredits fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static LineItemCredits fromJson(JsonObject jsonObj) { LineItemCredits obj = new LineItemCredits(); - obj.cnId = JsonUtil.getString(json, "cn_id"); + obj.cnId = JsonUtil.getString(jsonObj, "cn_id"); - obj.appliedAmount = JsonUtil.getDouble(json, "applied_amount"); + obj.appliedAmount = JsonUtil.getDouble(jsonObj, "applied_amount"); - obj.lineItemId = JsonUtil.getString(json, "line_item_id"); + obj.lineItemId = JsonUtil.getString(jsonObj, "line_item_id"); return obj; } @@ -2330,38 +2303,42 @@ public static ValidationStatus fromString(String value) { } public static LineItemAddresses fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static LineItemAddresses fromJson(JsonObject jsonObj) { LineItemAddresses obj = new LineItemAddresses(); - obj.lineItemId = JsonUtil.getString(json, "line_item_id"); + obj.lineItemId = JsonUtil.getString(jsonObj, "line_item_id"); - obj.firstName = JsonUtil.getString(json, "first_name"); + obj.firstName = JsonUtil.getString(jsonObj, "first_name"); - obj.lastName = JsonUtil.getString(json, "last_name"); + obj.lastName = JsonUtil.getString(jsonObj, "last_name"); - obj.email = JsonUtil.getString(json, "email"); + obj.email = JsonUtil.getString(jsonObj, "email"); - obj.company = JsonUtil.getString(json, "company"); + obj.company = JsonUtil.getString(jsonObj, "company"); - obj.phone = JsonUtil.getString(json, "phone"); + obj.phone = JsonUtil.getString(jsonObj, "phone"); - obj.line1 = JsonUtil.getString(json, "line1"); + obj.line1 = JsonUtil.getString(jsonObj, "line1"); - obj.line2 = JsonUtil.getString(json, "line2"); + obj.line2 = JsonUtil.getString(jsonObj, "line2"); - obj.line3 = JsonUtil.getString(json, "line3"); + obj.line3 = JsonUtil.getString(jsonObj, "line3"); - obj.city = JsonUtil.getString(json, "city"); + obj.city = JsonUtil.getString(jsonObj, "city"); - obj.stateCode = JsonUtil.getString(json, "state_code"); + obj.stateCode = JsonUtil.getString(jsonObj, "state_code"); - obj.state = JsonUtil.getString(json, "state"); + obj.state = JsonUtil.getString(jsonObj, "state"); - obj.country = JsonUtil.getString(json, "country"); + obj.country = JsonUtil.getString(jsonObj, "country"); - obj.zip = JsonUtil.getString(json, "zip"); + obj.zip = JsonUtil.getString(jsonObj, "zip"); obj.validationStatus = - ValidationStatus.fromString(JsonUtil.getString(json, "validation_status")); + ValidationStatus.fromString(JsonUtil.getString(jsonObj, "validation_status")); return obj; } @@ -2550,21 +2527,25 @@ public static DiscountType fromString(String value) { } public static Discounts fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Discounts fromJson(JsonObject jsonObj) { Discounts obj = new Discounts(); - obj.amount = JsonUtil.getLong(json, "amount"); + obj.amount = JsonUtil.getLong(jsonObj, "amount"); - obj.description = JsonUtil.getString(json, "description"); + obj.description = JsonUtil.getString(jsonObj, "description"); - obj.lineItemId = JsonUtil.getString(json, "line_item_id"); + obj.lineItemId = JsonUtil.getString(jsonObj, "line_item_id"); - obj.entityType = EntityType.fromString(JsonUtil.getString(json, "entity_type")); + obj.entityType = EntityType.fromString(JsonUtil.getString(jsonObj, "entity_type")); - obj.discountType = DiscountType.fromString(JsonUtil.getString(json, "discount_type")); + obj.discountType = DiscountType.fromString(JsonUtil.getString(jsonObj, "discount_type")); - obj.entityId = JsonUtil.getString(json, "entity_id"); + obj.entityId = JsonUtil.getString(jsonObj, "entity_id"); - obj.couponSetCode = JsonUtil.getString(json, "coupon_set_code"); + obj.couponSetCode = JsonUtil.getString(jsonObj, "coupon_set_code"); return obj; } @@ -2631,13 +2612,17 @@ public String getDescription() { } public static Taxes fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Taxes fromJson(JsonObject jsonObj) { Taxes obj = new Taxes(); - obj.name = JsonUtil.getString(json, "name"); + obj.name = JsonUtil.getString(jsonObj, "name"); - obj.amount = JsonUtil.getLong(json, "amount"); + obj.amount = JsonUtil.getLong(jsonObj, "amount"); - obj.description = JsonUtil.getString(json, "description"); + obj.description = JsonUtil.getString(jsonObj, "description"); return obj; } @@ -2686,11 +2671,15 @@ public String getRegistrationNumber() { } public static TaxOrigin fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static TaxOrigin fromJson(JsonObject jsonObj) { TaxOrigin obj = new TaxOrigin(); - obj.country = JsonUtil.getString(json, "country"); + obj.country = JsonUtil.getString(jsonObj, "country"); - obj.registrationNumber = JsonUtil.getString(json, "registration_number"); + obj.registrationNumber = JsonUtil.getString(jsonObj, "registration_number"); return obj; } @@ -2794,19 +2783,23 @@ public static TxnStatus fromString(String value) { } public static LinkedPayments fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static LinkedPayments fromJson(JsonObject jsonObj) { LinkedPayments obj = new LinkedPayments(); - obj.txnId = JsonUtil.getString(json, "txn_id"); + obj.txnId = JsonUtil.getString(jsonObj, "txn_id"); - obj.appliedAmount = JsonUtil.getLong(json, "applied_amount"); + obj.appliedAmount = JsonUtil.getLong(jsonObj, "applied_amount"); - obj.appliedAt = JsonUtil.getTimestamp(json, "applied_at"); + obj.appliedAt = JsonUtil.getTimestamp(jsonObj, "applied_at"); - obj.txnStatus = TxnStatus.fromString(JsonUtil.getString(json, "txn_status")); + obj.txnStatus = TxnStatus.fromString(JsonUtil.getString(jsonObj, "txn_status")); - obj.txnDate = JsonUtil.getTimestamp(json, "txn_date"); + obj.txnDate = JsonUtil.getTimestamp(jsonObj, "txn_date"); - obj.txnAmount = JsonUtil.getLong(json, "txn_amount"); + obj.txnAmount = JsonUtil.getLong(jsonObj, "txn_amount"); return obj; } @@ -3001,26 +2994,30 @@ public static AuthorizationReason fromString(String value) { } public static ReferenceTransactions fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static ReferenceTransactions fromJson(JsonObject jsonObj) { ReferenceTransactions obj = new ReferenceTransactions(); - obj.appliedAmount = JsonUtil.getLong(json, "applied_amount"); + obj.appliedAmount = JsonUtil.getLong(jsonObj, "applied_amount"); - obj.appliedAt = JsonUtil.getTimestamp(json, "applied_at"); + obj.appliedAt = JsonUtil.getTimestamp(jsonObj, "applied_at"); - obj.txnId = JsonUtil.getString(json, "txn_id"); + obj.txnId = JsonUtil.getString(jsonObj, "txn_id"); - obj.txnStatus = TxnStatus.fromString(JsonUtil.getString(json, "txn_status")); + obj.txnStatus = TxnStatus.fromString(JsonUtil.getString(jsonObj, "txn_status")); - obj.txnDate = JsonUtil.getTimestamp(json, "txn_date"); + obj.txnDate = JsonUtil.getTimestamp(jsonObj, "txn_date"); - obj.txnAmount = JsonUtil.getLong(json, "txn_amount"); + obj.txnAmount = JsonUtil.getLong(jsonObj, "txn_amount"); - obj.txnType = TxnType.fromString(JsonUtil.getString(json, "txn_type")); + obj.txnType = TxnType.fromString(JsonUtil.getString(jsonObj, "txn_type")); - obj.amountCapturable = JsonUtil.getLong(json, "amount_capturable"); + obj.amountCapturable = JsonUtil.getLong(jsonObj, "amount_capturable"); obj.authorizationReason = - AuthorizationReason.fromString(JsonUtil.getString(json, "authorization_reason")); + AuthorizationReason.fromString(JsonUtil.getString(jsonObj, "authorization_reason")); return obj; } @@ -3219,21 +3216,25 @@ public static RetryEngine fromString(String value) { } public static DunningAttempts fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static DunningAttempts fromJson(JsonObject jsonObj) { DunningAttempts obj = new DunningAttempts(); - obj.attempt = JsonUtil.getInteger(json, "attempt"); + obj.attempt = JsonUtil.getInteger(jsonObj, "attempt"); - obj.transactionId = JsonUtil.getString(json, "transaction_id"); + obj.transactionId = JsonUtil.getString(jsonObj, "transaction_id"); - obj.dunningType = DunningType.fromString(JsonUtil.getString(json, "dunning_type")); + obj.dunningType = DunningType.fromString(JsonUtil.getString(jsonObj, "dunning_type")); - obj.createdAt = JsonUtil.getTimestamp(json, "created_at"); + obj.createdAt = JsonUtil.getTimestamp(jsonObj, "created_at"); - obj.txnStatus = TxnStatus.fromString(JsonUtil.getString(json, "txn_status")); + obj.txnStatus = TxnStatus.fromString(JsonUtil.getString(jsonObj, "txn_status")); - obj.txnAmount = JsonUtil.getLong(json, "txn_amount"); + obj.txnAmount = JsonUtil.getLong(jsonObj, "txn_amount"); - obj.retryEngine = RetryEngine.fromString(JsonUtil.getString(json, "retry_engine")); + obj.retryEngine = RetryEngine.fromString(JsonUtil.getString(jsonObj, "retry_engine")); return obj; } @@ -3433,23 +3434,28 @@ public static TaxApplication fromString(String value) { } public static AppliedCredits fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static AppliedCredits fromJson(JsonObject jsonObj) { AppliedCredits obj = new AppliedCredits(); - obj.cnId = JsonUtil.getString(json, "cn_id"); + obj.cnId = JsonUtil.getString(jsonObj, "cn_id"); - obj.appliedAmount = JsonUtil.getLong(json, "applied_amount"); + obj.appliedAmount = JsonUtil.getLong(jsonObj, "applied_amount"); - obj.appliedAt = JsonUtil.getTimestamp(json, "applied_at"); + obj.appliedAt = JsonUtil.getTimestamp(jsonObj, "applied_at"); - obj.cnReasonCode = CnReasonCode.fromString(JsonUtil.getString(json, "cn_reason_code")); + obj.cnReasonCode = CnReasonCode.fromString(JsonUtil.getString(jsonObj, "cn_reason_code")); - obj.cnCreateReasonCode = JsonUtil.getString(json, "cn_create_reason_code"); + obj.cnCreateReasonCode = JsonUtil.getString(jsonObj, "cn_create_reason_code"); - obj.cnDate = JsonUtil.getTimestamp(json, "cn_date"); + obj.cnDate = JsonUtil.getTimestamp(jsonObj, "cn_date"); - obj.cnStatus = CnStatus.fromString(JsonUtil.getString(json, "cn_status")); + obj.cnStatus = CnStatus.fromString(JsonUtil.getString(jsonObj, "cn_status")); - obj.taxApplication = TaxApplication.fromString(JsonUtil.getString(json, "tax_application")); + obj.taxApplication = + TaxApplication.fromString(JsonUtil.getString(jsonObj, "tax_application")); return obj; } @@ -3621,19 +3627,23 @@ public static CnStatus fromString(String value) { } public static AdjustmentCreditNotes fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static AdjustmentCreditNotes fromJson(JsonObject jsonObj) { AdjustmentCreditNotes obj = new AdjustmentCreditNotes(); - obj.cnId = JsonUtil.getString(json, "cn_id"); + obj.cnId = JsonUtil.getString(jsonObj, "cn_id"); - obj.cnReasonCode = CnReasonCode.fromString(JsonUtil.getString(json, "cn_reason_code")); + obj.cnReasonCode = CnReasonCode.fromString(JsonUtil.getString(jsonObj, "cn_reason_code")); - obj.cnCreateReasonCode = JsonUtil.getString(json, "cn_create_reason_code"); + obj.cnCreateReasonCode = JsonUtil.getString(jsonObj, "cn_create_reason_code"); - obj.cnDate = JsonUtil.getTimestamp(json, "cn_date"); + obj.cnDate = JsonUtil.getTimestamp(jsonObj, "cn_date"); - obj.cnTotal = JsonUtil.getLong(json, "cn_total"); + obj.cnTotal = JsonUtil.getLong(jsonObj, "cn_total"); - obj.cnStatus = CnStatus.fromString(JsonUtil.getString(json, "cn_status")); + obj.cnStatus = CnStatus.fromString(JsonUtil.getString(jsonObj, "cn_status")); return obj; } @@ -3792,19 +3802,23 @@ public static CnStatus fromString(String value) { } public static IssuedCreditNotes fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static IssuedCreditNotes fromJson(JsonObject jsonObj) { IssuedCreditNotes obj = new IssuedCreditNotes(); - obj.cnId = JsonUtil.getString(json, "cn_id"); + obj.cnId = JsonUtil.getString(jsonObj, "cn_id"); - obj.cnReasonCode = CnReasonCode.fromString(JsonUtil.getString(json, "cn_reason_code")); + obj.cnReasonCode = CnReasonCode.fromString(JsonUtil.getString(jsonObj, "cn_reason_code")); - obj.cnCreateReasonCode = JsonUtil.getString(json, "cn_create_reason_code"); + obj.cnCreateReasonCode = JsonUtil.getString(jsonObj, "cn_create_reason_code"); - obj.cnDate = JsonUtil.getTimestamp(json, "cn_date"); + obj.cnDate = JsonUtil.getTimestamp(jsonObj, "cn_date"); - obj.cnTotal = JsonUtil.getLong(json, "cn_total"); + obj.cnTotal = JsonUtil.getLong(jsonObj, "cn_total"); - obj.cnStatus = CnStatus.fromString(JsonUtil.getString(json, "cn_status")); + obj.cnStatus = CnStatus.fromString(JsonUtil.getString(jsonObj, "cn_status")); return obj; } @@ -3969,23 +3983,27 @@ public static OrderType fromString(String value) { } public static LinkedOrders fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static LinkedOrders fromJson(JsonObject jsonObj) { LinkedOrders obj = new LinkedOrders(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.documentNumber = JsonUtil.getString(json, "document_number"); + obj.documentNumber = JsonUtil.getString(jsonObj, "document_number"); - obj.status = Status.fromString(JsonUtil.getString(json, "status")); + obj.status = Status.fromString(JsonUtil.getString(jsonObj, "status")); - obj.orderType = OrderType.fromString(JsonUtil.getString(json, "order_type")); + obj.orderType = OrderType.fromString(JsonUtil.getString(jsonObj, "order_type")); - obj.referenceId = JsonUtil.getString(json, "reference_id"); + obj.referenceId = JsonUtil.getString(jsonObj, "reference_id"); - obj.fulfillmentStatus = JsonUtil.getString(json, "fulfillment_status"); + obj.fulfillmentStatus = JsonUtil.getString(jsonObj, "fulfillment_status"); - obj.batchId = JsonUtil.getString(json, "batch_id"); + obj.batchId = JsonUtil.getString(jsonObj, "batch_id"); - obj.createdAt = JsonUtil.getTimestamp(json, "created_at"); + obj.createdAt = JsonUtil.getTimestamp(jsonObj, "created_at"); return obj; } @@ -4104,13 +4122,17 @@ public static EntityType fromString(String value) { } public static Notes fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Notes fromJson(JsonObject jsonObj) { Notes obj = new Notes(); - obj.note = JsonUtil.getString(json, "note"); + obj.note = JsonUtil.getString(jsonObj, "note"); - obj.entityId = JsonUtil.getString(json, "entity_id"); + obj.entityId = JsonUtil.getString(jsonObj, "entity_id"); - obj.entityType = EntityType.fromString(JsonUtil.getString(json, "entity_type")); + obj.entityType = EntityType.fromString(JsonUtil.getString(jsonObj, "entity_type")); return obj; } @@ -4251,36 +4273,40 @@ public static ValidationStatus fromString(String value) { } public static ShippingAddress fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static ShippingAddress fromJson(JsonObject jsonObj) { ShippingAddress obj = new ShippingAddress(); - obj.firstName = JsonUtil.getString(json, "first_name"); + obj.firstName = JsonUtil.getString(jsonObj, "first_name"); - obj.lastName = JsonUtil.getString(json, "last_name"); + obj.lastName = JsonUtil.getString(jsonObj, "last_name"); - obj.email = JsonUtil.getString(json, "email"); + obj.email = JsonUtil.getString(jsonObj, "email"); - obj.company = JsonUtil.getString(json, "company"); + obj.company = JsonUtil.getString(jsonObj, "company"); - obj.phone = JsonUtil.getString(json, "phone"); + obj.phone = JsonUtil.getString(jsonObj, "phone"); - obj.line1 = JsonUtil.getString(json, "line1"); + obj.line1 = JsonUtil.getString(jsonObj, "line1"); - obj.line2 = JsonUtil.getString(json, "line2"); + obj.line2 = JsonUtil.getString(jsonObj, "line2"); - obj.line3 = JsonUtil.getString(json, "line3"); + obj.line3 = JsonUtil.getString(jsonObj, "line3"); - obj.city = JsonUtil.getString(json, "city"); + obj.city = JsonUtil.getString(jsonObj, "city"); - obj.stateCode = JsonUtil.getString(json, "state_code"); + obj.stateCode = JsonUtil.getString(jsonObj, "state_code"); - obj.state = JsonUtil.getString(json, "state"); + obj.state = JsonUtil.getString(jsonObj, "state"); - obj.country = JsonUtil.getString(json, "country"); + obj.country = JsonUtil.getString(jsonObj, "country"); - obj.zip = JsonUtil.getString(json, "zip"); + obj.zip = JsonUtil.getString(jsonObj, "zip"); obj.validationStatus = - ValidationStatus.fromString(JsonUtil.getString(json, "validation_status")); + ValidationStatus.fromString(JsonUtil.getString(jsonObj, "validation_status")); return obj; } @@ -4468,36 +4494,40 @@ public static ValidationStatus fromString(String value) { } public static BillingAddress fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static BillingAddress fromJson(JsonObject jsonObj) { BillingAddress obj = new BillingAddress(); - obj.firstName = JsonUtil.getString(json, "first_name"); + obj.firstName = JsonUtil.getString(jsonObj, "first_name"); - obj.lastName = JsonUtil.getString(json, "last_name"); + obj.lastName = JsonUtil.getString(jsonObj, "last_name"); - obj.email = JsonUtil.getString(json, "email"); + obj.email = JsonUtil.getString(jsonObj, "email"); - obj.company = JsonUtil.getString(json, "company"); + obj.company = JsonUtil.getString(jsonObj, "company"); - obj.phone = JsonUtil.getString(json, "phone"); + obj.phone = JsonUtil.getString(jsonObj, "phone"); - obj.line1 = JsonUtil.getString(json, "line1"); + obj.line1 = JsonUtil.getString(jsonObj, "line1"); - obj.line2 = JsonUtil.getString(json, "line2"); + obj.line2 = JsonUtil.getString(jsonObj, "line2"); - obj.line3 = JsonUtil.getString(json, "line3"); + obj.line3 = JsonUtil.getString(jsonObj, "line3"); - obj.city = JsonUtil.getString(json, "city"); + obj.city = JsonUtil.getString(jsonObj, "city"); - obj.stateCode = JsonUtil.getString(json, "state_code"); + obj.stateCode = JsonUtil.getString(jsonObj, "state_code"); - obj.state = JsonUtil.getString(json, "state"); + obj.state = JsonUtil.getString(jsonObj, "state"); - obj.country = JsonUtil.getString(json, "country"); + obj.country = JsonUtil.getString(jsonObj, "country"); - obj.zip = JsonUtil.getString(json, "zip"); + obj.zip = JsonUtil.getString(jsonObj, "zip"); obj.validationStatus = - ValidationStatus.fromString(JsonUtil.getString(json, "validation_status")); + ValidationStatus.fromString(JsonUtil.getString(jsonObj, "validation_status")); return obj; } @@ -4593,11 +4623,15 @@ public String getDescriptor() { } public static StatementDescriptor fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static StatementDescriptor fromJson(JsonObject jsonObj) { StatementDescriptor obj = new StatementDescriptor(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.descriptor = JsonUtil.getString(json, "descriptor"); + obj.descriptor = JsonUtil.getString(jsonObj, "descriptor"); return obj; } @@ -4698,15 +4732,19 @@ public static Status fromString(String value) { } public static Einvoice fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Einvoice fromJson(JsonObject jsonObj) { Einvoice obj = new Einvoice(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.referenceNumber = JsonUtil.getString(json, "reference_number"); + obj.referenceNumber = JsonUtil.getString(jsonObj, "reference_number"); - obj.status = Status.fromString(JsonUtil.getString(json, "status")); + obj.status = Status.fromString(JsonUtil.getString(jsonObj, "status")); - obj.message = JsonUtil.getString(json, "message"); + obj.message = JsonUtil.getString(jsonObj, "message"); return obj; } @@ -4758,14 +4796,18 @@ public java.util.Map getOrganizationAddress() { } public static SiteDetailsAtCreation fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static SiteDetailsAtCreation fromJson(JsonObject jsonObj) { SiteDetailsAtCreation obj = new SiteDetailsAtCreation(); - obj.timezone = JsonUtil.getString(json, "timezone"); + obj.timezone = JsonUtil.getString(jsonObj, "timezone"); - String __organizationAddressJson = JsonUtil.getObject(json, "organization_address"); + JsonObject __organizationAddressObj = JsonUtil.getJsonObject(jsonObj, "organization_address"); obj.organizationAddress = - __organizationAddressJson != null - ? JsonUtil.parseJsonObjectToMap(__organizationAddressJson) + __organizationAddressObj != null + ? JsonUtil.parseJsonObjectToMap(__organizationAddressObj) : new java.util.HashMap<>(); return obj; diff --git a/src/main/java/com/chargebee/v4/models/invoice/responses/DownloadEinvoiceResponse.java b/src/main/java/com/chargebee/v4/models/invoice/responses/DownloadEinvoiceResponse.java index 1ea58941..ef474735 100644 --- a/src/main/java/com/chargebee/v4/models/invoice/responses/DownloadEinvoiceResponse.java +++ b/src/main/java/com/chargebee/v4/models/invoice/responses/DownloadEinvoiceResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; import java.util.List; @@ -28,15 +29,11 @@ public static DownloadEinvoiceResponse fromJson(String json) { /** Parse JSON response into DownloadEinvoiceResponse object with HTTP response. */ public static DownloadEinvoiceResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __downloadsJson = JsonUtil.getArray(json, "downloads"); - if (__downloadsJson != null) { - builder.downloads( - JsonUtil.parseObjectArray(__downloadsJson).stream() - .map(Download::fromJson) - .collect(java.util.stream.Collectors.toList())); - } + builder.downloads( + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "downloads"), Download::fromJson)); builder.httpResponse(httpResponse); return builder.build(); diff --git a/src/main/java/com/chargebee/v4/models/invoice/responses/ImportInvoiceResponse.java b/src/main/java/com/chargebee/v4/models/invoice/responses/ImportInvoiceResponse.java index 1b42024a..eba13ffa 100644 --- a/src/main/java/com/chargebee/v4/models/invoice/responses/ImportInvoiceResponse.java +++ b/src/main/java/com/chargebee/v4/models/invoice/responses/ImportInvoiceResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -32,16 +33,17 @@ public static ImportInvoiceResponse fromJson(String json) { /** Parse JSON response into ImportInvoiceResponse object with HTTP response. */ public static ImportInvoiceResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __invoiceJson = JsonUtil.getObject(json, "invoice"); - if (__invoiceJson != null) { - builder.invoice(Invoice.fromJson(__invoiceJson)); + JsonObject __invoiceObj = JsonUtil.getJsonObject(jsonObj, "invoice"); + if (__invoiceObj != null) { + builder.invoice(Invoice.fromJson(__invoiceObj)); } - String __creditNoteJson = JsonUtil.getObject(json, "credit_note"); - if (__creditNoteJson != null) { - builder.creditNote(CreditNote.fromJson(__creditNoteJson)); + JsonObject __creditNoteObj = JsonUtil.getJsonObject(jsonObj, "credit_note"); + if (__creditNoteObj != null) { + builder.creditNote(CreditNote.fromJson(__creditNoteObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceAddAddonChargeResponse.java b/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceAddAddonChargeResponse.java index 247c3f24..05ff3c70 100644 --- a/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceAddAddonChargeResponse.java +++ b/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceAddAddonChargeResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static InvoiceAddAddonChargeResponse fromJson(String json) { /** Parse JSON response into InvoiceAddAddonChargeResponse object with HTTP response. */ public static InvoiceAddAddonChargeResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __invoiceJson = JsonUtil.getObject(json, "invoice"); - if (__invoiceJson != null) { - builder.invoice(Invoice.fromJson(__invoiceJson)); + JsonObject __invoiceObj = JsonUtil.getJsonObject(jsonObj, "invoice"); + if (__invoiceObj != null) { + builder.invoice(Invoice.fromJson(__invoiceObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceAddChargeItemResponse.java b/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceAddChargeItemResponse.java index 2b60b6f5..2778d711 100644 --- a/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceAddChargeItemResponse.java +++ b/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceAddChargeItemResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static InvoiceAddChargeItemResponse fromJson(String json) { /** Parse JSON response into InvoiceAddChargeItemResponse object with HTTP response. */ public static InvoiceAddChargeItemResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __invoiceJson = JsonUtil.getObject(json, "invoice"); - if (__invoiceJson != null) { - builder.invoice(Invoice.fromJson(__invoiceJson)); + JsonObject __invoiceObj = JsonUtil.getJsonObject(jsonObj, "invoice"); + if (__invoiceObj != null) { + builder.invoice(Invoice.fromJson(__invoiceObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceAddChargeResponse.java b/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceAddChargeResponse.java index f412113c..0fa14cff 100644 --- a/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceAddChargeResponse.java +++ b/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceAddChargeResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static InvoiceAddChargeResponse fromJson(String json) { /** Parse JSON response into InvoiceAddChargeResponse object with HTTP response. */ public static InvoiceAddChargeResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __invoiceJson = JsonUtil.getObject(json, "invoice"); - if (__invoiceJson != null) { - builder.invoice(Invoice.fromJson(__invoiceJson)); + JsonObject __invoiceObj = JsonUtil.getJsonObject(jsonObj, "invoice"); + if (__invoiceObj != null) { + builder.invoice(Invoice.fromJson(__invoiceObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceApplyCreditsResponse.java b/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceApplyCreditsResponse.java index dfacdbc0..c5e98288 100644 --- a/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceApplyCreditsResponse.java +++ b/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceApplyCreditsResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static InvoiceApplyCreditsResponse fromJson(String json) { /** Parse JSON response into InvoiceApplyCreditsResponse object with HTTP response. */ public static InvoiceApplyCreditsResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __invoiceJson = JsonUtil.getObject(json, "invoice"); - if (__invoiceJson != null) { - builder.invoice(Invoice.fromJson(__invoiceJson)); + JsonObject __invoiceObj = JsonUtil.getJsonObject(jsonObj, "invoice"); + if (__invoiceObj != null) { + builder.invoice(Invoice.fromJson(__invoiceObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceApplyPaymentScheduleSchemeResponse.java b/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceApplyPaymentScheduleSchemeResponse.java index 3a5d04d1..ce2bc430 100644 --- a/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceApplyPaymentScheduleSchemeResponse.java +++ b/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceApplyPaymentScheduleSchemeResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -30,11 +31,12 @@ public static InvoiceApplyPaymentScheduleSchemeResponse fromJson(String json) { public static InvoiceApplyPaymentScheduleSchemeResponse fromJson( String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __invoiceJson = JsonUtil.getObject(json, "invoice"); - if (__invoiceJson != null) { - builder.invoice(Invoice.fromJson(__invoiceJson)); + JsonObject __invoiceObj = JsonUtil.getJsonObject(jsonObj, "invoice"); + if (__invoiceObj != null) { + builder.invoice(Invoice.fromJson(__invoiceObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceApplyPaymentsResponse.java b/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceApplyPaymentsResponse.java index 93498b0e..50ddd29f 100644 --- a/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceApplyPaymentsResponse.java +++ b/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceApplyPaymentsResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static InvoiceApplyPaymentsResponse fromJson(String json) { /** Parse JSON response into InvoiceApplyPaymentsResponse object with HTTP response. */ public static InvoiceApplyPaymentsResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __invoiceJson = JsonUtil.getObject(json, "invoice"); - if (__invoiceJson != null) { - builder.invoice(Invoice.fromJson(__invoiceJson)); + JsonObject __invoiceObj = JsonUtil.getJsonObject(jsonObj, "invoice"); + if (__invoiceObj != null) { + builder.invoice(Invoice.fromJson(__invoiceObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceChargeAddonResponse.java b/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceChargeAddonResponse.java index 6bd97bdf..253bfe85 100644 --- a/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceChargeAddonResponse.java +++ b/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceChargeAddonResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static InvoiceChargeAddonResponse fromJson(String json) { /** Parse JSON response into InvoiceChargeAddonResponse object with HTTP response. */ public static InvoiceChargeAddonResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __invoiceJson = JsonUtil.getObject(json, "invoice"); - if (__invoiceJson != null) { - builder.invoice(Invoice.fromJson(__invoiceJson)); + JsonObject __invoiceObj = JsonUtil.getJsonObject(jsonObj, "invoice"); + if (__invoiceObj != null) { + builder.invoice(Invoice.fromJson(__invoiceObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceChargeResponse.java b/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceChargeResponse.java index 68dfe109..4f72a8c5 100644 --- a/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceChargeResponse.java +++ b/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceChargeResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -26,11 +27,12 @@ public static InvoiceChargeResponse fromJson(String json) { /** Parse JSON response into InvoiceChargeResponse object with HTTP response. */ public static InvoiceChargeResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __invoiceJson = JsonUtil.getObject(json, "invoice"); - if (__invoiceJson != null) { - builder.invoice(Invoice.fromJson(__invoiceJson)); + JsonObject __invoiceObj = JsonUtil.getJsonObject(jsonObj, "invoice"); + if (__invoiceObj != null) { + builder.invoice(Invoice.fromJson(__invoiceObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceCloseResponse.java b/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceCloseResponse.java index af2a6ab2..e8653792 100644 --- a/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceCloseResponse.java +++ b/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceCloseResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -26,11 +27,12 @@ public static InvoiceCloseResponse fromJson(String json) { /** Parse JSON response into InvoiceCloseResponse object with HTTP response. */ public static InvoiceCloseResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __invoiceJson = JsonUtil.getObject(json, "invoice"); - if (__invoiceJson != null) { - builder.invoice(Invoice.fromJson(__invoiceJson)); + JsonObject __invoiceObj = JsonUtil.getJsonObject(jsonObj, "invoice"); + if (__invoiceObj != null) { + builder.invoice(Invoice.fromJson(__invoiceObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceCollectPaymentResponse.java b/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceCollectPaymentResponse.java index d1b55ceb..538a69b0 100644 --- a/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceCollectPaymentResponse.java +++ b/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceCollectPaymentResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -33,16 +34,17 @@ public static InvoiceCollectPaymentResponse fromJson(String json) { /** Parse JSON response into InvoiceCollectPaymentResponse object with HTTP response. */ public static InvoiceCollectPaymentResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __invoiceJson = JsonUtil.getObject(json, "invoice"); - if (__invoiceJson != null) { - builder.invoice(Invoice.fromJson(__invoiceJson)); + JsonObject __invoiceObj = JsonUtil.getJsonObject(jsonObj, "invoice"); + if (__invoiceObj != null) { + builder.invoice(Invoice.fromJson(__invoiceObj)); } - String __transactionJson = JsonUtil.getObject(json, "transaction"); - if (__transactionJson != null) { - builder.transaction(Transaction.fromJson(__transactionJson)); + JsonObject __transactionObj = JsonUtil.getJsonObject(jsonObj, "transaction"); + if (__transactionObj != null) { + builder.transaction(Transaction.fromJson(__transactionObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceCreateForChargeItemResponse.java b/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceCreateForChargeItemResponse.java index b85b19db..b82588a6 100644 --- a/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceCreateForChargeItemResponse.java +++ b/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceCreateForChargeItemResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static InvoiceCreateForChargeItemResponse fromJson(String json) { /** Parse JSON response into InvoiceCreateForChargeItemResponse object with HTTP response. */ public static InvoiceCreateForChargeItemResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __invoiceJson = JsonUtil.getObject(json, "invoice"); - if (__invoiceJson != null) { - builder.invoice(Invoice.fromJson(__invoiceJson)); + JsonObject __invoiceObj = JsonUtil.getJsonObject(jsonObj, "invoice"); + if (__invoiceObj != null) { + builder.invoice(Invoice.fromJson(__invoiceObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceCreateForChargeItemsAndChargesResponse.java b/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceCreateForChargeItemsAndChargesResponse.java index 157caa25..17df98b8 100644 --- a/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceCreateForChargeItemsAndChargesResponse.java +++ b/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceCreateForChargeItemsAndChargesResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -31,11 +32,12 @@ public static InvoiceCreateForChargeItemsAndChargesResponse fromJson(String json public static InvoiceCreateForChargeItemsAndChargesResponse fromJson( String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __invoiceJson = JsonUtil.getObject(json, "invoice"); - if (__invoiceJson != null) { - builder.invoice(Invoice.fromJson(__invoiceJson)); + JsonObject __invoiceObj = JsonUtil.getJsonObject(jsonObj, "invoice"); + if (__invoiceObj != null) { + builder.invoice(Invoice.fromJson(__invoiceObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceCreateResponse.java b/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceCreateResponse.java index b01edfa6..024d95cc 100644 --- a/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceCreateResponse.java +++ b/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceCreateResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -26,11 +27,12 @@ public static InvoiceCreateResponse fromJson(String json) { /** Parse JSON response into InvoiceCreateResponse object with HTTP response. */ public static InvoiceCreateResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __invoiceJson = JsonUtil.getObject(json, "invoice"); - if (__invoiceJson != null) { - builder.invoice(Invoice.fromJson(__invoiceJson)); + JsonObject __invoiceObj = JsonUtil.getJsonObject(jsonObj, "invoice"); + if (__invoiceObj != null) { + builder.invoice(Invoice.fromJson(__invoiceObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceDeleteImportedResponse.java b/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceDeleteImportedResponse.java index 8c110501..eb9709d3 100644 --- a/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceDeleteImportedResponse.java +++ b/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceDeleteImportedResponse.java @@ -8,6 +8,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -35,17 +36,16 @@ public static InvoiceDeleteImportedResponse fromJson(String json) { /** Parse JSON response into InvoiceDeleteImportedResponse object with HTTP response. */ public static InvoiceDeleteImportedResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __invoiceJson = JsonUtil.getObject(json, "invoice"); - if (__invoiceJson != null) { - builder.invoice(Invoice.fromJson(__invoiceJson)); + JsonObject __invoiceObj = JsonUtil.getJsonObject(jsonObj, "invoice"); + if (__invoiceObj != null) { + builder.invoice(Invoice.fromJson(__invoiceObj)); } builder.creditNotes( - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "credit_notes")).stream() - .map(CreditNote::fromJson) - .collect(java.util.stream.Collectors.toList())); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "credit_notes"), CreditNote::fromJson)); builder.httpResponse(httpResponse); return builder.build(); diff --git a/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceDeleteLineItemsResponse.java b/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceDeleteLineItemsResponse.java index 3428cb2d..ff380e35 100644 --- a/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceDeleteLineItemsResponse.java +++ b/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceDeleteLineItemsResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static InvoiceDeleteLineItemsResponse fromJson(String json) { /** Parse JSON response into InvoiceDeleteLineItemsResponse object with HTTP response. */ public static InvoiceDeleteLineItemsResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __invoiceJson = JsonUtil.getObject(json, "invoice"); - if (__invoiceJson != null) { - builder.invoice(Invoice.fromJson(__invoiceJson)); + JsonObject __invoiceObj = JsonUtil.getJsonObject(jsonObj, "invoice"); + if (__invoiceObj != null) { + builder.invoice(Invoice.fromJson(__invoiceObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceDeleteResponse.java b/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceDeleteResponse.java index 42db1efe..47805165 100644 --- a/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceDeleteResponse.java +++ b/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceDeleteResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -26,11 +27,12 @@ public static InvoiceDeleteResponse fromJson(String json) { /** Parse JSON response into InvoiceDeleteResponse object with HTTP response. */ public static InvoiceDeleteResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __invoiceJson = JsonUtil.getObject(json, "invoice"); - if (__invoiceJson != null) { - builder.invoice(Invoice.fromJson(__invoiceJson)); + JsonObject __invoiceObj = JsonUtil.getJsonObject(jsonObj, "invoice"); + if (__invoiceObj != null) { + builder.invoice(Invoice.fromJson(__invoiceObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceListPaymentReferenceNumbersResponse.java b/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceListPaymentReferenceNumbersResponse.java index 8969a183..1807f378 100644 --- a/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceListPaymentReferenceNumbersResponse.java +++ b/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceListPaymentReferenceNumbersResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.exceptions.ChargebeeException; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; import com.chargebee.v4.services.InvoiceService; import com.chargebee.v4.models.invoice.params.InvoiceListPaymentReferenceNumbersParams; @@ -46,13 +47,14 @@ private InvoiceListPaymentReferenceNumbersResponse( */ public static InvoiceListPaymentReferenceNumbersResponse fromJson(String json) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(InvoiceListPaymentReferenceNumbersItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "list"), + InvoiceListPaymentReferenceNumbersItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new InvoiceListPaymentReferenceNumbersResponse(list, nextOffset, null, null, null); } catch (Exception e) { @@ -71,13 +73,14 @@ public static InvoiceListPaymentReferenceNumbersResponse fromJson( InvoiceListPaymentReferenceNumbersParams originalParams, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(InvoiceListPaymentReferenceNumbersItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "list"), + InvoiceListPaymentReferenceNumbersItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new InvoiceListPaymentReferenceNumbersResponse( list, nextOffset, service, originalParams, httpResponse); @@ -187,11 +190,16 @@ public PaymentReferenceNumber getPaymentReferenceNumber() { } public static InvoiceListPaymentReferenceNumbersItem fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static InvoiceListPaymentReferenceNumbersItem fromJson(JsonObject jsonObj) { InvoiceListPaymentReferenceNumbersItem item = new InvoiceListPaymentReferenceNumbersItem(); - String __paymentReferenceNumberJson = JsonUtil.getObject(json, "payment_reference_number"); - if (__paymentReferenceNumberJson != null) { - item.paymentReferenceNumber = PaymentReferenceNumber.fromJson(__paymentReferenceNumberJson); + JsonObject __paymentReferenceNumberObj = + JsonUtil.getJsonObject(jsonObj, "payment_reference_number"); + if (__paymentReferenceNumberObj != null) { + item.paymentReferenceNumber = PaymentReferenceNumber.fromJson(__paymentReferenceNumberObj); } return item; diff --git a/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceListResponse.java b/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceListResponse.java index 82447959..21d0168f 100644 --- a/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceListResponse.java +++ b/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceListResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.exceptions.ChargebeeException; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; import com.chargebee.v4.services.InvoiceService; import com.chargebee.v4.models.invoice.params.InvoiceListParams; @@ -43,13 +44,12 @@ private InvoiceListResponse( */ public static InvoiceListResponse fromJson(String json) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(InvoiceListItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "list"), InvoiceListItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new InvoiceListResponse(list, nextOffset, null, null, null); } catch (Exception e) { @@ -67,13 +67,12 @@ public static InvoiceListResponse fromJson( InvoiceListParams originalParams, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(InvoiceListItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "list"), InvoiceListItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new InvoiceListResponse(list, nextOffset, service, originalParams, httpResponse); } catch (Exception e) { @@ -173,11 +172,15 @@ public Invoice getInvoice() { } public static InvoiceListItem fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static InvoiceListItem fromJson(JsonObject jsonObj) { InvoiceListItem item = new InvoiceListItem(); - String __invoiceJson = JsonUtil.getObject(json, "invoice"); - if (__invoiceJson != null) { - item.invoice = Invoice.fromJson(__invoiceJson); + JsonObject __invoiceObj = JsonUtil.getJsonObject(jsonObj, "invoice"); + if (__invoiceObj != null) { + item.invoice = Invoice.fromJson(__invoiceObj); } return item; diff --git a/src/main/java/com/chargebee/v4/models/invoice/responses/InvoicePauseDunningResponse.java b/src/main/java/com/chargebee/v4/models/invoice/responses/InvoicePauseDunningResponse.java index 06590331..f4a3cd29 100644 --- a/src/main/java/com/chargebee/v4/models/invoice/responses/InvoicePauseDunningResponse.java +++ b/src/main/java/com/chargebee/v4/models/invoice/responses/InvoicePauseDunningResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static InvoicePauseDunningResponse fromJson(String json) { /** Parse JSON response into InvoicePauseDunningResponse object with HTTP response. */ public static InvoicePauseDunningResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __invoiceJson = JsonUtil.getObject(json, "invoice"); - if (__invoiceJson != null) { - builder.invoice(Invoice.fromJson(__invoiceJson)); + JsonObject __invoiceObj = JsonUtil.getJsonObject(jsonObj, "invoice"); + if (__invoiceObj != null) { + builder.invoice(Invoice.fromJson(__invoiceObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/invoice/responses/InvoicePaymentSchedulesResponse.java b/src/main/java/com/chargebee/v4/models/invoice/responses/InvoicePaymentSchedulesResponse.java index e0a25192..57db6c57 100644 --- a/src/main/java/com/chargebee/v4/models/invoice/responses/InvoicePaymentSchedulesResponse.java +++ b/src/main/java/com/chargebee/v4/models/invoice/responses/InvoicePaymentSchedulesResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; import java.util.List; @@ -28,15 +29,12 @@ public static InvoicePaymentSchedulesResponse fromJson(String json) { /** Parse JSON response into InvoicePaymentSchedulesResponse object with HTTP response. */ public static InvoicePaymentSchedulesResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __paymentSchedulesJson = JsonUtil.getArray(json, "payment_schedules"); - if (__paymentSchedulesJson != null) { - builder.paymentSchedules( - JsonUtil.parseObjectArray(__paymentSchedulesJson).stream() - .map(PaymentSchedule::fromJson) - .collect(java.util.stream.Collectors.toList())); - } + builder.paymentSchedules( + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "payment_schedules"), PaymentSchedule::fromJson)); builder.httpResponse(httpResponse); return builder.build(); diff --git a/src/main/java/com/chargebee/v4/models/invoice/responses/InvoicePdfResponse.java b/src/main/java/com/chargebee/v4/models/invoice/responses/InvoicePdfResponse.java index 47b5c672..2da219e8 100644 --- a/src/main/java/com/chargebee/v4/models/invoice/responses/InvoicePdfResponse.java +++ b/src/main/java/com/chargebee/v4/models/invoice/responses/InvoicePdfResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** Immutable response object for InvoicePdf operation. Contains the response data from the API. */ @@ -24,11 +25,12 @@ public static InvoicePdfResponse fromJson(String json) { /** Parse JSON response into InvoicePdfResponse object with HTTP response. */ public static InvoicePdfResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __downloadJson = JsonUtil.getObject(json, "download"); - if (__downloadJson != null) { - builder.download(Download.fromJson(__downloadJson)); + JsonObject __downloadObj = JsonUtil.getJsonObject(jsonObj, "download"); + if (__downloadObj != null) { + builder.download(Download.fromJson(__downloadObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceRecordPaymentResponse.java b/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceRecordPaymentResponse.java index ff42bea8..7b7e0cf0 100644 --- a/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceRecordPaymentResponse.java +++ b/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceRecordPaymentResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -33,16 +34,17 @@ public static InvoiceRecordPaymentResponse fromJson(String json) { /** Parse JSON response into InvoiceRecordPaymentResponse object with HTTP response. */ public static InvoiceRecordPaymentResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __invoiceJson = JsonUtil.getObject(json, "invoice"); - if (__invoiceJson != null) { - builder.invoice(Invoice.fromJson(__invoiceJson)); + JsonObject __invoiceObj = JsonUtil.getJsonObject(jsonObj, "invoice"); + if (__invoiceObj != null) { + builder.invoice(Invoice.fromJson(__invoiceObj)); } - String __transactionJson = JsonUtil.getObject(json, "transaction"); - if (__transactionJson != null) { - builder.transaction(Transaction.fromJson(__transactionJson)); + JsonObject __transactionObj = JsonUtil.getJsonObject(jsonObj, "transaction"); + if (__transactionObj != null) { + builder.transaction(Transaction.fromJson(__transactionObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceRecordRefundResponse.java b/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceRecordRefundResponse.java index 9389caf5..99a902a7 100644 --- a/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceRecordRefundResponse.java +++ b/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceRecordRefundResponse.java @@ -8,6 +8,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -39,21 +40,22 @@ public static InvoiceRecordRefundResponse fromJson(String json) { /** Parse JSON response into InvoiceRecordRefundResponse object with HTTP response. */ public static InvoiceRecordRefundResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __invoiceJson = JsonUtil.getObject(json, "invoice"); - if (__invoiceJson != null) { - builder.invoice(Invoice.fromJson(__invoiceJson)); + JsonObject __invoiceObj = JsonUtil.getJsonObject(jsonObj, "invoice"); + if (__invoiceObj != null) { + builder.invoice(Invoice.fromJson(__invoiceObj)); } - String __transactionJson = JsonUtil.getObject(json, "transaction"); - if (__transactionJson != null) { - builder.transaction(Transaction.fromJson(__transactionJson)); + JsonObject __transactionObj = JsonUtil.getJsonObject(jsonObj, "transaction"); + if (__transactionObj != null) { + builder.transaction(Transaction.fromJson(__transactionObj)); } - String __creditNoteJson = JsonUtil.getObject(json, "credit_note"); - if (__creditNoteJson != null) { - builder.creditNote(CreditNote.fromJson(__creditNoteJson)); + JsonObject __creditNoteObj = JsonUtil.getJsonObject(jsonObj, "credit_note"); + if (__creditNoteObj != null) { + builder.creditNote(CreditNote.fromJson(__creditNoteObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceRecordTaxWithheldResponse.java b/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceRecordTaxWithheldResponse.java index 7824f3e4..6963db7d 100644 --- a/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceRecordTaxWithheldResponse.java +++ b/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceRecordTaxWithheldResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static InvoiceRecordTaxWithheldResponse fromJson(String json) { /** Parse JSON response into InvoiceRecordTaxWithheldResponse object with HTTP response. */ public static InvoiceRecordTaxWithheldResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __invoiceJson = JsonUtil.getObject(json, "invoice"); - if (__invoiceJson != null) { - builder.invoice(Invoice.fromJson(__invoiceJson)); + JsonObject __invoiceObj = JsonUtil.getJsonObject(jsonObj, "invoice"); + if (__invoiceObj != null) { + builder.invoice(Invoice.fromJson(__invoiceObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceRefundResponse.java b/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceRefundResponse.java index a7d76e93..e7f4a43b 100644 --- a/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceRefundResponse.java +++ b/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceRefundResponse.java @@ -8,6 +8,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -38,21 +39,22 @@ public static InvoiceRefundResponse fromJson(String json) { /** Parse JSON response into InvoiceRefundResponse object with HTTP response. */ public static InvoiceRefundResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __invoiceJson = JsonUtil.getObject(json, "invoice"); - if (__invoiceJson != null) { - builder.invoice(Invoice.fromJson(__invoiceJson)); + JsonObject __invoiceObj = JsonUtil.getJsonObject(jsonObj, "invoice"); + if (__invoiceObj != null) { + builder.invoice(Invoice.fromJson(__invoiceObj)); } - String __transactionJson = JsonUtil.getObject(json, "transaction"); - if (__transactionJson != null) { - builder.transaction(Transaction.fromJson(__transactionJson)); + JsonObject __transactionObj = JsonUtil.getJsonObject(jsonObj, "transaction"); + if (__transactionObj != null) { + builder.transaction(Transaction.fromJson(__transactionObj)); } - String __creditNoteJson = JsonUtil.getObject(json, "credit_note"); - if (__creditNoteJson != null) { - builder.creditNote(CreditNote.fromJson(__creditNoteJson)); + JsonObject __creditNoteObj = JsonUtil.getJsonObject(jsonObj, "credit_note"); + if (__creditNoteObj != null) { + builder.creditNote(CreditNote.fromJson(__creditNoteObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceRemoveCreditNoteResponse.java b/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceRemoveCreditNoteResponse.java index 30bc0861..923ddaf2 100644 --- a/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceRemoveCreditNoteResponse.java +++ b/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceRemoveCreditNoteResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -33,16 +34,17 @@ public static InvoiceRemoveCreditNoteResponse fromJson(String json) { /** Parse JSON response into InvoiceRemoveCreditNoteResponse object with HTTP response. */ public static InvoiceRemoveCreditNoteResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __invoiceJson = JsonUtil.getObject(json, "invoice"); - if (__invoiceJson != null) { - builder.invoice(Invoice.fromJson(__invoiceJson)); + JsonObject __invoiceObj = JsonUtil.getJsonObject(jsonObj, "invoice"); + if (__invoiceObj != null) { + builder.invoice(Invoice.fromJson(__invoiceObj)); } - String __creditNoteJson = JsonUtil.getObject(json, "credit_note"); - if (__creditNoteJson != null) { - builder.creditNote(CreditNote.fromJson(__creditNoteJson)); + JsonObject __creditNoteObj = JsonUtil.getJsonObject(jsonObj, "credit_note"); + if (__creditNoteObj != null) { + builder.creditNote(CreditNote.fromJson(__creditNoteObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceRemovePaymentResponse.java b/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceRemovePaymentResponse.java index e500cbe4..742af61f 100644 --- a/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceRemovePaymentResponse.java +++ b/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceRemovePaymentResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -33,16 +34,17 @@ public static InvoiceRemovePaymentResponse fromJson(String json) { /** Parse JSON response into InvoiceRemovePaymentResponse object with HTTP response. */ public static InvoiceRemovePaymentResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __invoiceJson = JsonUtil.getObject(json, "invoice"); - if (__invoiceJson != null) { - builder.invoice(Invoice.fromJson(__invoiceJson)); + JsonObject __invoiceObj = JsonUtil.getJsonObject(jsonObj, "invoice"); + if (__invoiceObj != null) { + builder.invoice(Invoice.fromJson(__invoiceObj)); } - String __transactionJson = JsonUtil.getObject(json, "transaction"); - if (__transactionJson != null) { - builder.transaction(Transaction.fromJson(__transactionJson)); + JsonObject __transactionObj = JsonUtil.getJsonObject(jsonObj, "transaction"); + if (__transactionObj != null) { + builder.transaction(Transaction.fromJson(__transactionObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceRemoveTaxWithheldResponse.java b/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceRemoveTaxWithheldResponse.java index a5f4ce7f..dad5eff4 100644 --- a/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceRemoveTaxWithheldResponse.java +++ b/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceRemoveTaxWithheldResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static InvoiceRemoveTaxWithheldResponse fromJson(String json) { /** Parse JSON response into InvoiceRemoveTaxWithheldResponse object with HTTP response. */ public static InvoiceRemoveTaxWithheldResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __invoiceJson = JsonUtil.getObject(json, "invoice"); - if (__invoiceJson != null) { - builder.invoice(Invoice.fromJson(__invoiceJson)); + JsonObject __invoiceObj = JsonUtil.getJsonObject(jsonObj, "invoice"); + if (__invoiceObj != null) { + builder.invoice(Invoice.fromJson(__invoiceObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceResumeDunningResponse.java b/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceResumeDunningResponse.java index 69cd0509..7652e763 100644 --- a/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceResumeDunningResponse.java +++ b/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceResumeDunningResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static InvoiceResumeDunningResponse fromJson(String json) { /** Parse JSON response into InvoiceResumeDunningResponse object with HTTP response. */ public static InvoiceResumeDunningResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __invoiceJson = JsonUtil.getObject(json, "invoice"); - if (__invoiceJson != null) { - builder.invoice(Invoice.fromJson(__invoiceJson)); + JsonObject __invoiceObj = JsonUtil.getJsonObject(jsonObj, "invoice"); + if (__invoiceObj != null) { + builder.invoice(Invoice.fromJson(__invoiceObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceRetrieveResponse.java b/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceRetrieveResponse.java index 01ecbc03..60360411 100644 --- a/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceRetrieveResponse.java +++ b/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceRetrieveResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static InvoiceRetrieveResponse fromJson(String json) { /** Parse JSON response into InvoiceRetrieveResponse object with HTTP response. */ public static InvoiceRetrieveResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __invoiceJson = JsonUtil.getObject(json, "invoice"); - if (__invoiceJson != null) { - builder.invoice(Invoice.fromJson(__invoiceJson)); + JsonObject __invoiceObj = JsonUtil.getJsonObject(jsonObj, "invoice"); + if (__invoiceObj != null) { + builder.invoice(Invoice.fromJson(__invoiceObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceStopDunningResponse.java b/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceStopDunningResponse.java index 0b90da57..c89d4acc 100644 --- a/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceStopDunningResponse.java +++ b/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceStopDunningResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static InvoiceStopDunningResponse fromJson(String json) { /** Parse JSON response into InvoiceStopDunningResponse object with HTTP response. */ public static InvoiceStopDunningResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __invoiceJson = JsonUtil.getObject(json, "invoice"); - if (__invoiceJson != null) { - builder.invoice(Invoice.fromJson(__invoiceJson)); + JsonObject __invoiceObj = JsonUtil.getJsonObject(jsonObj, "invoice"); + if (__invoiceObj != null) { + builder.invoice(Invoice.fromJson(__invoiceObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceSyncUsagesResponse.java b/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceSyncUsagesResponse.java index 00faa580..3324545a 100644 --- a/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceSyncUsagesResponse.java +++ b/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceSyncUsagesResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static InvoiceSyncUsagesResponse fromJson(String json) { /** Parse JSON response into InvoiceSyncUsagesResponse object with HTTP response. */ public static InvoiceSyncUsagesResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __invoiceJson = JsonUtil.getObject(json, "invoice"); - if (__invoiceJson != null) { - builder.invoice(Invoice.fromJson(__invoiceJson)); + JsonObject __invoiceObj = JsonUtil.getJsonObject(jsonObj, "invoice"); + if (__invoiceObj != null) { + builder.invoice(Invoice.fromJson(__invoiceObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceUpdateDetailsResponse.java b/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceUpdateDetailsResponse.java index dc02d80e..6406cb98 100644 --- a/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceUpdateDetailsResponse.java +++ b/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceUpdateDetailsResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static InvoiceUpdateDetailsResponse fromJson(String json) { /** Parse JSON response into InvoiceUpdateDetailsResponse object with HTTP response. */ public static InvoiceUpdateDetailsResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __invoiceJson = JsonUtil.getObject(json, "invoice"); - if (__invoiceJson != null) { - builder.invoice(Invoice.fromJson(__invoiceJson)); + JsonObject __invoiceObj = JsonUtil.getJsonObject(jsonObj, "invoice"); + if (__invoiceObj != null) { + builder.invoice(Invoice.fromJson(__invoiceObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceWriteOffResponse.java b/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceWriteOffResponse.java index bb4fd90c..a061918e 100644 --- a/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceWriteOffResponse.java +++ b/src/main/java/com/chargebee/v4/models/invoice/responses/InvoiceWriteOffResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -32,16 +33,17 @@ public static InvoiceWriteOffResponse fromJson(String json) { /** Parse JSON response into InvoiceWriteOffResponse object with HTTP response. */ public static InvoiceWriteOffResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __invoiceJson = JsonUtil.getObject(json, "invoice"); - if (__invoiceJson != null) { - builder.invoice(Invoice.fromJson(__invoiceJson)); + JsonObject __invoiceObj = JsonUtil.getJsonObject(jsonObj, "invoice"); + if (__invoiceObj != null) { + builder.invoice(Invoice.fromJson(__invoiceObj)); } - String __creditNoteJson = JsonUtil.getObject(json, "credit_note"); - if (__creditNoteJson != null) { - builder.creditNote(CreditNote.fromJson(__creditNoteJson)); + JsonObject __creditNoteObj = JsonUtil.getJsonObject(jsonObj, "credit_note"); + if (__creditNoteObj != null) { + builder.creditNote(CreditNote.fromJson(__creditNoteObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/invoice/responses/InvoicesForCustomerResponse.java b/src/main/java/com/chargebee/v4/models/invoice/responses/InvoicesForCustomerResponse.java index 01ce14aa..e4003af3 100644 --- a/src/main/java/com/chargebee/v4/models/invoice/responses/InvoicesForCustomerResponse.java +++ b/src/main/java/com/chargebee/v4/models/invoice/responses/InvoicesForCustomerResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.exceptions.ChargebeeException; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; import com.chargebee.v4.services.InvoiceService; import com.chargebee.v4.models.invoice.params.InvoicesForCustomerParams; @@ -48,13 +49,13 @@ private InvoicesForCustomerResponse( */ public static InvoicesForCustomerResponse fromJson(String json) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(InvoiceInvoicesForCustomerItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "list"), InvoiceInvoicesForCustomerItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new InvoicesForCustomerResponse(list, nextOffset, null, null, null, null); } catch (Exception e) { @@ -73,13 +74,13 @@ public static InvoicesForCustomerResponse fromJson( String customerId, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(InvoiceInvoicesForCustomerItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "list"), InvoiceInvoicesForCustomerItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new InvoicesForCustomerResponse( list, nextOffset, customerId, service, originalParams, httpResponse); @@ -180,11 +181,15 @@ public Invoice getInvoice() { } public static InvoiceInvoicesForCustomerItem fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static InvoiceInvoicesForCustomerItem fromJson(JsonObject jsonObj) { InvoiceInvoicesForCustomerItem item = new InvoiceInvoicesForCustomerItem(); - String __invoiceJson = JsonUtil.getObject(json, "invoice"); - if (__invoiceJson != null) { - item.invoice = Invoice.fromJson(__invoiceJson); + JsonObject __invoiceObj = JsonUtil.getJsonObject(jsonObj, "invoice"); + if (__invoiceObj != null) { + item.invoice = Invoice.fromJson(__invoiceObj); } return item; diff --git a/src/main/java/com/chargebee/v4/models/invoice/responses/InvoicesForSubscriptionResponse.java b/src/main/java/com/chargebee/v4/models/invoice/responses/InvoicesForSubscriptionResponse.java index 8440768f..d930ded1 100644 --- a/src/main/java/com/chargebee/v4/models/invoice/responses/InvoicesForSubscriptionResponse.java +++ b/src/main/java/com/chargebee/v4/models/invoice/responses/InvoicesForSubscriptionResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.exceptions.ChargebeeException; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; import com.chargebee.v4.services.InvoiceService; import com.chargebee.v4.models.invoice.params.InvoicesForSubscriptionParams; @@ -50,13 +51,13 @@ private InvoicesForSubscriptionResponse( */ public static InvoicesForSubscriptionResponse fromJson(String json) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(InvoiceInvoicesForSubscriptionItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "list"), InvoiceInvoicesForSubscriptionItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new InvoicesForSubscriptionResponse(list, nextOffset, null, null, null, null); } catch (Exception e) { @@ -75,13 +76,13 @@ public static InvoicesForSubscriptionResponse fromJson( String subscriptionId, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(InvoiceInvoicesForSubscriptionItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "list"), InvoiceInvoicesForSubscriptionItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new InvoicesForSubscriptionResponse( list, nextOffset, subscriptionId, service, originalParams, httpResponse); @@ -184,11 +185,15 @@ public Invoice getInvoice() { } public static InvoiceInvoicesForSubscriptionItem fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static InvoiceInvoicesForSubscriptionItem fromJson(JsonObject jsonObj) { InvoiceInvoicesForSubscriptionItem item = new InvoiceInvoicesForSubscriptionItem(); - String __invoiceJson = JsonUtil.getObject(json, "invoice"); - if (__invoiceJson != null) { - item.invoice = Invoice.fromJson(__invoiceJson); + JsonObject __invoiceObj = JsonUtil.getJsonObject(jsonObj, "invoice"); + if (__invoiceObj != null) { + item.invoice = Invoice.fromJson(__invoiceObj); } return item; diff --git a/src/main/java/com/chargebee/v4/models/invoice/responses/ResendEinvoiceResponse.java b/src/main/java/com/chargebee/v4/models/invoice/responses/ResendEinvoiceResponse.java index 4138f57e..06f53458 100644 --- a/src/main/java/com/chargebee/v4/models/invoice/responses/ResendEinvoiceResponse.java +++ b/src/main/java/com/chargebee/v4/models/invoice/responses/ResendEinvoiceResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -26,11 +27,12 @@ public static ResendEinvoiceResponse fromJson(String json) { /** Parse JSON response into ResendEinvoiceResponse object with HTTP response. */ public static ResendEinvoiceResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __invoiceJson = JsonUtil.getObject(json, "invoice"); - if (__invoiceJson != null) { - builder.invoice(Invoice.fromJson(__invoiceJson)); + JsonObject __invoiceObj = JsonUtil.getJsonObject(jsonObj, "invoice"); + if (__invoiceObj != null) { + builder.invoice(Invoice.fromJson(__invoiceObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/invoice/responses/SendEinvoiceResponse.java b/src/main/java/com/chargebee/v4/models/invoice/responses/SendEinvoiceResponse.java index 2cd32018..78c96268 100644 --- a/src/main/java/com/chargebee/v4/models/invoice/responses/SendEinvoiceResponse.java +++ b/src/main/java/com/chargebee/v4/models/invoice/responses/SendEinvoiceResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -26,11 +27,12 @@ public static SendEinvoiceResponse fromJson(String json) { /** Parse JSON response into SendEinvoiceResponse object with HTTP response. */ public static SendEinvoiceResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __invoiceJson = JsonUtil.getObject(json, "invoice"); - if (__invoiceJson != null) { - builder.invoice(Invoice.fromJson(__invoiceJson)); + JsonObject __invoiceObj = JsonUtil.getJsonObject(jsonObj, "invoice"); + if (__invoiceObj != null) { + builder.invoice(Invoice.fromJson(__invoiceObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/invoice/responses/VoidInvoiceResponse.java b/src/main/java/com/chargebee/v4/models/invoice/responses/VoidInvoiceResponse.java index 8fe30b22..225d1bd8 100644 --- a/src/main/java/com/chargebee/v4/models/invoice/responses/VoidInvoiceResponse.java +++ b/src/main/java/com/chargebee/v4/models/invoice/responses/VoidInvoiceResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** Immutable response object for VoidInvoice operation. Contains the response data from the API. */ @@ -30,16 +31,17 @@ public static VoidInvoiceResponse fromJson(String json) { /** Parse JSON response into VoidInvoiceResponse object with HTTP response. */ public static VoidInvoiceResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __invoiceJson = JsonUtil.getObject(json, "invoice"); - if (__invoiceJson != null) { - builder.invoice(Invoice.fromJson(__invoiceJson)); + JsonObject __invoiceObj = JsonUtil.getJsonObject(jsonObj, "invoice"); + if (__invoiceObj != null) { + builder.invoice(Invoice.fromJson(__invoiceObj)); } - String __creditNoteJson = JsonUtil.getObject(json, "credit_note"); - if (__creditNoteJson != null) { - builder.creditNote(CreditNote.fromJson(__creditNoteJson)); + JsonObject __creditNoteObj = JsonUtil.getJsonObject(jsonObj, "credit_note"); + if (__creditNoteObj != null) { + builder.creditNote(CreditNote.fromJson(__creditNoteObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/invoiceEstimate/InvoiceEstimate.java b/src/main/java/com/chargebee/v4/models/invoiceEstimate/InvoiceEstimate.java index 2644a1d6..9bec216b 100644 --- a/src/main/java/com/chargebee/v4/models/invoiceEstimate/InvoiceEstimate.java +++ b/src/main/java/com/chargebee/v4/models/invoiceEstimate/InvoiceEstimate.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.invoiceEstimate; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import java.math.BigDecimal; import java.sql.Timestamp; import java.util.List; @@ -134,67 +135,59 @@ public static PriceType fromString(String value) { } public static InvoiceEstimate fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static InvoiceEstimate fromJson(JsonObject jsonObj) { InvoiceEstimate obj = new InvoiceEstimate(); - obj.recurring = JsonUtil.getBoolean(json, "recurring"); + obj.recurring = JsonUtil.getBoolean(jsonObj, "recurring"); - obj.priceType = PriceType.fromString(JsonUtil.getString(json, "price_type")); + obj.priceType = PriceType.fromString(JsonUtil.getString(jsonObj, "price_type")); - obj.currencyCode = JsonUtil.getString(json, "currency_code"); + obj.currencyCode = JsonUtil.getString(jsonObj, "currency_code"); - obj.subTotal = JsonUtil.getLong(json, "sub_total"); + obj.subTotal = JsonUtil.getLong(jsonObj, "sub_total"); - obj.total = JsonUtil.getLong(json, "total"); + obj.total = JsonUtil.getLong(jsonObj, "total"); - obj.creditsApplied = JsonUtil.getLong(json, "credits_applied"); + obj.creditsApplied = JsonUtil.getLong(jsonObj, "credits_applied"); - obj.amountPaid = JsonUtil.getLong(json, "amount_paid"); + obj.amountPaid = JsonUtil.getLong(jsonObj, "amount_paid"); - obj.amountDue = JsonUtil.getLong(json, "amount_due"); + obj.amountDue = JsonUtil.getLong(jsonObj, "amount_due"); - obj.roundOffAmount = JsonUtil.getLong(json, "round_off_amount"); + obj.roundOffAmount = JsonUtil.getLong(jsonObj, "round_off_amount"); - obj.customerId = JsonUtil.getString(json, "customer_id"); + obj.customerId = JsonUtil.getString(jsonObj, "customer_id"); obj.lineItems = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "line_items")).stream() - .map(LineItems::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "line_items"), LineItems::fromJson); obj.lineItemTiers = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "line_item_tiers")).stream() - .map(LineItemTiers::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "line_item_tiers"), LineItemTiers::fromJson); obj.lineItemDiscounts = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "line_item_discounts")).stream() - .map(LineItemDiscounts::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "line_item_discounts"), LineItemDiscounts::fromJson); obj.lineItemTaxes = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "line_item_taxes")).stream() - .map(LineItemTaxes::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "line_item_taxes"), LineItemTaxes::fromJson); obj.lineItemCredits = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "line_item_credits")).stream() - .map(LineItemCredits::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "line_item_credits"), LineItemCredits::fromJson); obj.lineItemAddresses = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "line_item_addresses")).stream() - .map(LineItemAddresses::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "line_item_addresses"), LineItemAddresses::fromJson); obj.discounts = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "discounts")).stream() - .map(Discounts::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "discounts"), Discounts::fromJson); - obj.taxes = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "taxes")).stream() - .map(Taxes::fromJson) - .collect(java.util.stream.Collectors.toList()); + obj.taxes = JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "taxes"), Taxes::fromJson); return obj; } @@ -536,58 +529,62 @@ public static TaxExemptReason fromString(String value) { } public static LineItems fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static LineItems fromJson(JsonObject jsonObj) { LineItems obj = new LineItems(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.subscriptionId = JsonUtil.getString(json, "subscription_id"); + obj.subscriptionId = JsonUtil.getString(jsonObj, "subscription_id"); - obj.dateFrom = JsonUtil.getTimestamp(json, "date_from"); + obj.dateFrom = JsonUtil.getTimestamp(jsonObj, "date_from"); - obj.dateTo = JsonUtil.getTimestamp(json, "date_to"); + obj.dateTo = JsonUtil.getTimestamp(jsonObj, "date_to"); - obj.unitAmount = JsonUtil.getLong(json, "unit_amount"); + obj.unitAmount = JsonUtil.getLong(jsonObj, "unit_amount"); - obj.quantity = JsonUtil.getInteger(json, "quantity"); + obj.quantity = JsonUtil.getInteger(jsonObj, "quantity"); - obj.amount = JsonUtil.getLong(json, "amount"); + obj.amount = JsonUtil.getLong(jsonObj, "amount"); - obj.pricingModel = PricingModel.fromString(JsonUtil.getString(json, "pricing_model")); + obj.pricingModel = PricingModel.fromString(JsonUtil.getString(jsonObj, "pricing_model")); - obj.isTaxed = JsonUtil.getBoolean(json, "is_taxed"); + obj.isTaxed = JsonUtil.getBoolean(jsonObj, "is_taxed"); - obj.taxAmount = JsonUtil.getLong(json, "tax_amount"); + obj.taxAmount = JsonUtil.getLong(jsonObj, "tax_amount"); - obj.taxRate = JsonUtil.getDouble(json, "tax_rate"); + obj.taxRate = JsonUtil.getDouble(jsonObj, "tax_rate"); - obj.unitAmountInDecimal = JsonUtil.getString(json, "unit_amount_in_decimal"); + obj.unitAmountInDecimal = JsonUtil.getString(jsonObj, "unit_amount_in_decimal"); - obj.quantityInDecimal = JsonUtil.getString(json, "quantity_in_decimal"); + obj.quantityInDecimal = JsonUtil.getString(jsonObj, "quantity_in_decimal"); - obj.amountInDecimal = JsonUtil.getString(json, "amount_in_decimal"); + obj.amountInDecimal = JsonUtil.getString(jsonObj, "amount_in_decimal"); - obj.discountAmount = JsonUtil.getLong(json, "discount_amount"); + obj.discountAmount = JsonUtil.getLong(jsonObj, "discount_amount"); - obj.itemLevelDiscountAmount = JsonUtil.getLong(json, "item_level_discount_amount"); + obj.itemLevelDiscountAmount = JsonUtil.getLong(jsonObj, "item_level_discount_amount"); - obj.metered = JsonUtil.getBoolean(json, "metered"); + obj.metered = JsonUtil.getBoolean(jsonObj, "metered"); - obj.isPercentagePricing = JsonUtil.getBoolean(json, "is_percentage_pricing"); + obj.isPercentagePricing = JsonUtil.getBoolean(jsonObj, "is_percentage_pricing"); - obj.referenceLineItemId = JsonUtil.getString(json, "reference_line_item_id"); + obj.referenceLineItemId = JsonUtil.getString(jsonObj, "reference_line_item_id"); - obj.description = JsonUtil.getString(json, "description"); + obj.description = JsonUtil.getString(jsonObj, "description"); - obj.entityDescription = JsonUtil.getString(json, "entity_description"); + obj.entityDescription = JsonUtil.getString(jsonObj, "entity_description"); - obj.entityType = EntityType.fromString(JsonUtil.getString(json, "entity_type")); + obj.entityType = EntityType.fromString(JsonUtil.getString(jsonObj, "entity_type")); obj.taxExemptReason = - TaxExemptReason.fromString(JsonUtil.getString(json, "tax_exempt_reason")); + TaxExemptReason.fromString(JsonUtil.getString(jsonObj, "tax_exempt_reason")); - obj.entityId = JsonUtil.getString(json, "entity_id"); + obj.entityId = JsonUtil.getString(jsonObj, "entity_id"); - obj.customerId = JsonUtil.getString(json, "customer_id"); + obj.customerId = JsonUtil.getString(jsonObj, "customer_id"); return obj; } @@ -802,29 +799,33 @@ public static PricingType fromString(String value) { } public static LineItemTiers fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static LineItemTiers fromJson(JsonObject jsonObj) { LineItemTiers obj = new LineItemTiers(); - obj.lineItemId = JsonUtil.getString(json, "line_item_id"); + obj.lineItemId = JsonUtil.getString(jsonObj, "line_item_id"); - obj.startingUnit = JsonUtil.getInteger(json, "starting_unit"); + obj.startingUnit = JsonUtil.getInteger(jsonObj, "starting_unit"); - obj.endingUnit = JsonUtil.getInteger(json, "ending_unit"); + obj.endingUnit = JsonUtil.getInteger(jsonObj, "ending_unit"); - obj.quantityUsed = JsonUtil.getInteger(json, "quantity_used"); + obj.quantityUsed = JsonUtil.getInteger(jsonObj, "quantity_used"); - obj.unitAmount = JsonUtil.getLong(json, "unit_amount"); + obj.unitAmount = JsonUtil.getLong(jsonObj, "unit_amount"); - obj.startingUnitInDecimal = JsonUtil.getString(json, "starting_unit_in_decimal"); + obj.startingUnitInDecimal = JsonUtil.getString(jsonObj, "starting_unit_in_decimal"); - obj.endingUnitInDecimal = JsonUtil.getString(json, "ending_unit_in_decimal"); + obj.endingUnitInDecimal = JsonUtil.getString(jsonObj, "ending_unit_in_decimal"); - obj.quantityUsedInDecimal = JsonUtil.getString(json, "quantity_used_in_decimal"); + obj.quantityUsedInDecimal = JsonUtil.getString(jsonObj, "quantity_used_in_decimal"); - obj.unitAmountInDecimal = JsonUtil.getString(json, "unit_amount_in_decimal"); + obj.unitAmountInDecimal = JsonUtil.getString(jsonObj, "unit_amount_in_decimal"); - obj.pricingType = PricingType.fromString(JsonUtil.getString(json, "pricing_type")); + obj.pricingType = PricingType.fromString(JsonUtil.getString(jsonObj, "pricing_type")); - obj.packageSize = JsonUtil.getInteger(json, "package_size"); + obj.packageSize = JsonUtil.getInteger(jsonObj, "package_size"); return obj; } @@ -959,17 +960,21 @@ public static DiscountType fromString(String value) { } public static LineItemDiscounts fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static LineItemDiscounts fromJson(JsonObject jsonObj) { LineItemDiscounts obj = new LineItemDiscounts(); - obj.lineItemId = JsonUtil.getString(json, "line_item_id"); + obj.lineItemId = JsonUtil.getString(jsonObj, "line_item_id"); - obj.discountType = DiscountType.fromString(JsonUtil.getString(json, "discount_type")); + obj.discountType = DiscountType.fromString(JsonUtil.getString(jsonObj, "discount_type")); - obj.couponId = JsonUtil.getString(json, "coupon_id"); + obj.couponId = JsonUtil.getString(jsonObj, "coupon_id"); - obj.entityId = JsonUtil.getString(json, "entity_id"); + obj.entityId = JsonUtil.getString(jsonObj, "entity_id"); - obj.discountAmount = JsonUtil.getLong(json, "discount_amount"); + obj.discountAmount = JsonUtil.getLong(jsonObj, "discount_amount"); return obj; } @@ -1129,37 +1134,41 @@ public static TaxJurisType fromString(String value) { } public static LineItemTaxes fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static LineItemTaxes fromJson(JsonObject jsonObj) { LineItemTaxes obj = new LineItemTaxes(); - obj.lineItemId = JsonUtil.getString(json, "line_item_id"); + obj.lineItemId = JsonUtil.getString(jsonObj, "line_item_id"); - obj.taxName = JsonUtil.getString(json, "tax_name"); + obj.taxName = JsonUtil.getString(jsonObj, "tax_name"); - obj.taxRate = JsonUtil.getDouble(json, "tax_rate"); + obj.taxRate = JsonUtil.getDouble(jsonObj, "tax_rate"); - obj.dateTo = JsonUtil.getTimestamp(json, "date_to"); + obj.dateTo = JsonUtil.getTimestamp(jsonObj, "date_to"); - obj.dateFrom = JsonUtil.getTimestamp(json, "date_from"); + obj.dateFrom = JsonUtil.getTimestamp(jsonObj, "date_from"); - obj.proratedTaxableAmount = JsonUtil.getBigDecimal(json, "prorated_taxable_amount"); + obj.proratedTaxableAmount = JsonUtil.getBigDecimal(jsonObj, "prorated_taxable_amount"); - obj.isPartialTaxApplied = JsonUtil.getBoolean(json, "is_partial_tax_applied"); + obj.isPartialTaxApplied = JsonUtil.getBoolean(jsonObj, "is_partial_tax_applied"); - obj.isNonComplianceTax = JsonUtil.getBoolean(json, "is_non_compliance_tax"); + obj.isNonComplianceTax = JsonUtil.getBoolean(jsonObj, "is_non_compliance_tax"); - obj.taxableAmount = JsonUtil.getLong(json, "taxable_amount"); + obj.taxableAmount = JsonUtil.getLong(jsonObj, "taxable_amount"); - obj.taxAmount = JsonUtil.getLong(json, "tax_amount"); + obj.taxAmount = JsonUtil.getLong(jsonObj, "tax_amount"); - obj.taxJurisType = TaxJurisType.fromString(JsonUtil.getString(json, "tax_juris_type")); + obj.taxJurisType = TaxJurisType.fromString(JsonUtil.getString(jsonObj, "tax_juris_type")); - obj.taxJurisName = JsonUtil.getString(json, "tax_juris_name"); + obj.taxJurisName = JsonUtil.getString(jsonObj, "tax_juris_name"); - obj.taxJurisCode = JsonUtil.getString(json, "tax_juris_code"); + obj.taxJurisCode = JsonUtil.getString(jsonObj, "tax_juris_code"); - obj.taxAmountInLocalCurrency = JsonUtil.getLong(json, "tax_amount_in_local_currency"); + obj.taxAmountInLocalCurrency = JsonUtil.getLong(jsonObj, "tax_amount_in_local_currency"); - obj.localCurrencyCode = JsonUtil.getString(json, "local_currency_code"); + obj.localCurrencyCode = JsonUtil.getString(jsonObj, "local_currency_code"); return obj; } @@ -1264,13 +1273,17 @@ public String getLineItemId() { } public static LineItemCredits fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static LineItemCredits fromJson(JsonObject jsonObj) { LineItemCredits obj = new LineItemCredits(); - obj.cnId = JsonUtil.getString(json, "cn_id"); + obj.cnId = JsonUtil.getString(jsonObj, "cn_id"); - obj.appliedAmount = JsonUtil.getDouble(json, "applied_amount"); + obj.appliedAmount = JsonUtil.getDouble(jsonObj, "applied_amount"); - obj.lineItemId = JsonUtil.getString(json, "line_item_id"); + obj.lineItemId = JsonUtil.getString(jsonObj, "line_item_id"); return obj; } @@ -1416,38 +1429,42 @@ public static ValidationStatus fromString(String value) { } public static LineItemAddresses fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static LineItemAddresses fromJson(JsonObject jsonObj) { LineItemAddresses obj = new LineItemAddresses(); - obj.lineItemId = JsonUtil.getString(json, "line_item_id"); + obj.lineItemId = JsonUtil.getString(jsonObj, "line_item_id"); - obj.firstName = JsonUtil.getString(json, "first_name"); + obj.firstName = JsonUtil.getString(jsonObj, "first_name"); - obj.lastName = JsonUtil.getString(json, "last_name"); + obj.lastName = JsonUtil.getString(jsonObj, "last_name"); - obj.email = JsonUtil.getString(json, "email"); + obj.email = JsonUtil.getString(jsonObj, "email"); - obj.company = JsonUtil.getString(json, "company"); + obj.company = JsonUtil.getString(jsonObj, "company"); - obj.phone = JsonUtil.getString(json, "phone"); + obj.phone = JsonUtil.getString(jsonObj, "phone"); - obj.line1 = JsonUtil.getString(json, "line1"); + obj.line1 = JsonUtil.getString(jsonObj, "line1"); - obj.line2 = JsonUtil.getString(json, "line2"); + obj.line2 = JsonUtil.getString(jsonObj, "line2"); - obj.line3 = JsonUtil.getString(json, "line3"); + obj.line3 = JsonUtil.getString(jsonObj, "line3"); - obj.city = JsonUtil.getString(json, "city"); + obj.city = JsonUtil.getString(jsonObj, "city"); - obj.stateCode = JsonUtil.getString(json, "state_code"); + obj.stateCode = JsonUtil.getString(jsonObj, "state_code"); - obj.state = JsonUtil.getString(json, "state"); + obj.state = JsonUtil.getString(jsonObj, "state"); - obj.country = JsonUtil.getString(json, "country"); + obj.country = JsonUtil.getString(jsonObj, "country"); - obj.zip = JsonUtil.getString(json, "zip"); + obj.zip = JsonUtil.getString(jsonObj, "zip"); obj.validationStatus = - ValidationStatus.fromString(JsonUtil.getString(json, "validation_status")); + ValidationStatus.fromString(JsonUtil.getString(jsonObj, "validation_status")); return obj; } @@ -1636,21 +1653,25 @@ public static DiscountType fromString(String value) { } public static Discounts fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Discounts fromJson(JsonObject jsonObj) { Discounts obj = new Discounts(); - obj.amount = JsonUtil.getLong(json, "amount"); + obj.amount = JsonUtil.getLong(jsonObj, "amount"); - obj.description = JsonUtil.getString(json, "description"); + obj.description = JsonUtil.getString(jsonObj, "description"); - obj.lineItemId = JsonUtil.getString(json, "line_item_id"); + obj.lineItemId = JsonUtil.getString(jsonObj, "line_item_id"); - obj.entityType = EntityType.fromString(JsonUtil.getString(json, "entity_type")); + obj.entityType = EntityType.fromString(JsonUtil.getString(jsonObj, "entity_type")); - obj.discountType = DiscountType.fromString(JsonUtil.getString(json, "discount_type")); + obj.discountType = DiscountType.fromString(JsonUtil.getString(jsonObj, "discount_type")); - obj.entityId = JsonUtil.getString(json, "entity_id"); + obj.entityId = JsonUtil.getString(jsonObj, "entity_id"); - obj.couponSetCode = JsonUtil.getString(json, "coupon_set_code"); + obj.couponSetCode = JsonUtil.getString(jsonObj, "coupon_set_code"); return obj; } @@ -1717,13 +1738,17 @@ public String getDescription() { } public static Taxes fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Taxes fromJson(JsonObject jsonObj) { Taxes obj = new Taxes(); - obj.name = JsonUtil.getString(json, "name"); + obj.name = JsonUtil.getString(jsonObj, "name"); - obj.amount = JsonUtil.getLong(json, "amount"); + obj.amount = JsonUtil.getLong(jsonObj, "amount"); - obj.description = JsonUtil.getString(json, "description"); + obj.description = JsonUtil.getString(jsonObj, "description"); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/item/Item.java b/src/main/java/com/chargebee/v4/models/item/Item.java index 167a0c9b..d3b56a6a 100644 --- a/src/main/java/com/chargebee/v4/models/item/Item.java +++ b/src/main/java/com/chargebee/v4/models/item/Item.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.item; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import java.math.BigDecimal; import java.sql.Timestamp; import java.util.List; @@ -331,9 +332,12 @@ public static Channel fromString(String value) { } public static Item fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Item fromJson(JsonObject jsonObj) { Item obj = new Item(); - // Parse JSON to extract all keys for custom field extraction java.util.Set knownFields = new java.util.HashSet<>(); knownFields.add("id"); @@ -394,115 +398,81 @@ public static Item fromJson(String json) { knownFields.add("bundle_configuration"); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.name = JsonUtil.getString(json, "name"); + obj.name = JsonUtil.getString(jsonObj, "name"); - obj.externalName = JsonUtil.getString(json, "external_name"); + obj.externalName = JsonUtil.getString(jsonObj, "external_name"); - obj.description = JsonUtil.getString(json, "description"); + obj.description = JsonUtil.getString(jsonObj, "description"); - obj.status = Status.fromString(JsonUtil.getString(json, "status")); + obj.status = Status.fromString(JsonUtil.getString(jsonObj, "status")); - obj.resourceVersion = JsonUtil.getLong(json, "resource_version"); + obj.resourceVersion = JsonUtil.getLong(jsonObj, "resource_version"); - obj.updatedAt = JsonUtil.getTimestamp(json, "updated_at"); + obj.updatedAt = JsonUtil.getTimestamp(jsonObj, "updated_at"); - obj.itemFamilyId = JsonUtil.getString(json, "item_family_id"); + obj.itemFamilyId = JsonUtil.getString(jsonObj, "item_family_id"); - obj.type = Type.fromString(JsonUtil.getString(json, "type")); + obj.type = Type.fromString(JsonUtil.getString(jsonObj, "type")); - obj.isShippable = JsonUtil.getBoolean(json, "is_shippable"); + obj.isShippable = JsonUtil.getBoolean(jsonObj, "is_shippable"); - obj.isGiftable = JsonUtil.getBoolean(json, "is_giftable"); + obj.isGiftable = JsonUtil.getBoolean(jsonObj, "is_giftable"); - obj.redirectUrl = JsonUtil.getString(json, "redirect_url"); + obj.redirectUrl = JsonUtil.getString(jsonObj, "redirect_url"); - obj.enabledForCheckout = JsonUtil.getBoolean(json, "enabled_for_checkout"); + obj.enabledForCheckout = JsonUtil.getBoolean(jsonObj, "enabled_for_checkout"); - obj.enabledInPortal = JsonUtil.getBoolean(json, "enabled_in_portal"); + obj.enabledInPortal = JsonUtil.getBoolean(jsonObj, "enabled_in_portal"); - obj.includedInMrr = JsonUtil.getBoolean(json, "included_in_mrr"); + obj.includedInMrr = JsonUtil.getBoolean(jsonObj, "included_in_mrr"); obj.itemApplicability = - ItemApplicability.fromString(JsonUtil.getString(json, "item_applicability")); + ItemApplicability.fromString(JsonUtil.getString(jsonObj, "item_applicability")); - obj.giftClaimRedirectUrl = JsonUtil.getString(json, "gift_claim_redirect_url"); + obj.giftClaimRedirectUrl = JsonUtil.getString(jsonObj, "gift_claim_redirect_url"); - obj.unit = JsonUtil.getString(json, "unit"); + obj.unit = JsonUtil.getString(jsonObj, "unit"); - obj.metered = JsonUtil.getBoolean(json, "metered"); + obj.metered = JsonUtil.getBoolean(jsonObj, "metered"); obj.usageCalculation = - UsageCalculation.fromString(JsonUtil.getString(json, "usage_calculation")); + UsageCalculation.fromString(JsonUtil.getString(jsonObj, "usage_calculation")); - obj.isPercentagePricing = JsonUtil.getBoolean(json, "is_percentage_pricing"); + obj.isPercentagePricing = JsonUtil.getBoolean(jsonObj, "is_percentage_pricing"); - obj.archivedAt = JsonUtil.getTimestamp(json, "archived_at"); + obj.archivedAt = JsonUtil.getTimestamp(jsonObj, "archived_at"); - obj.channel = Channel.fromString(JsonUtil.getString(json, "channel")); + obj.channel = Channel.fromString(JsonUtil.getString(jsonObj, "channel")); - String __metadataJson = JsonUtil.getObject(json, "metadata"); + JsonObject __metadataObj = JsonUtil.getJsonObject(jsonObj, "metadata"); obj.metadata = - __metadataJson != null - ? JsonUtil.parseJsonObjectToMap(__metadataJson) + __metadataObj != null + ? JsonUtil.parseJsonObjectToMap(__metadataObj) : new java.util.HashMap<>(); - obj.deleted = JsonUtil.getBoolean(json, "deleted"); + obj.deleted = JsonUtil.getBoolean(jsonObj, "deleted"); - obj.businessEntityId = JsonUtil.getString(json, "business_entity_id"); + obj.businessEntityId = JsonUtil.getString(jsonObj, "business_entity_id"); obj.applicableItems = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "applicable_items")).stream() - .map(ApplicableItems::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "applicable_items"), ApplicableItems::fromJson); obj.bundleItems = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "bundle_items")).stream() - .map(BundleItems::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "bundle_items"), BundleItems::fromJson); - String __bundleConfigurationJson = JsonUtil.getObject(json, "bundle_configuration"); - if (__bundleConfigurationJson != null) { - obj.bundleConfiguration = BundleConfiguration.fromJson(__bundleConfigurationJson); + JsonObject __bundleConfigurationObj = JsonUtil.getJsonObject(jsonObj, "bundle_configuration"); + if (__bundleConfigurationObj != null) { + obj.bundleConfiguration = BundleConfiguration.fromJson(__bundleConfigurationObj); } - // Extract custom fields (fields starting with cf_) - obj.customFields = extractCustomFields(json, knownFields); + obj.customFields = JsonUtil.extractCustomFields(jsonObj, knownFields); return obj; } - /** - * Helper method to extract custom fields from JSON. Custom fields are fields that start with - * "cf_" and are not in the known fields set. - * - * @param json JSON string to parse - * @param knownFields set of known field names - * @return map of custom fields - */ - private static java.util.Map extractCustomFields( - String json, java.util.Set knownFields) { - java.util.Map customFields = new java.util.HashMap<>(); - try { - // Parse the entire JSON as a map - java.util.Map allFields = JsonUtil.parseJsonObjectToMap(json); - if (allFields != null) { - for (java.util.Map.Entry entry : allFields.entrySet()) { - String key = entry.getKey(); - // Include fields that start with "cf_" and are not in knownFields - if (key != null && key.startsWith("cf_") && !knownFields.contains(key)) { - customFields.put( - key, entry.getValue() != null ? String.valueOf(entry.getValue()) : null); - } - } - } - } catch (Exception e) { - // If parsing fails, return empty map - } - return customFields; - } - @Override public String toString() { return "Item{" @@ -652,9 +622,13 @@ public String getId() { } public static ApplicableItems fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static ApplicableItems fromJson(JsonObject jsonObj) { ApplicableItems obj = new ApplicableItems(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); return obj; } @@ -734,15 +708,19 @@ public static ItemType fromString(String value) { } public static BundleItems fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static BundleItems fromJson(JsonObject jsonObj) { BundleItems obj = new BundleItems(); - obj.itemId = JsonUtil.getString(json, "item_id"); + obj.itemId = JsonUtil.getString(jsonObj, "item_id"); - obj.itemType = ItemType.fromString(JsonUtil.getString(json, "item_type")); + obj.itemType = ItemType.fromString(JsonUtil.getString(jsonObj, "item_type")); - obj.quantity = JsonUtil.getInteger(json, "quantity"); + obj.quantity = JsonUtil.getInteger(jsonObj, "quantity"); - obj.priceAllocation = JsonUtil.getBigDecimal(json, "price_allocation"); + obj.priceAllocation = JsonUtil.getBigDecimal(jsonObj, "price_allocation"); return obj; } @@ -815,9 +793,13 @@ public static Type fromString(String value) { } public static BundleConfiguration fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static BundleConfiguration fromJson(JsonObject jsonObj) { BundleConfiguration obj = new BundleConfiguration(); - obj.type = Type.fromString(JsonUtil.getString(json, "type")); + obj.type = Type.fromString(JsonUtil.getString(jsonObj, "type")); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/item/responses/ItemCreateResponse.java b/src/main/java/com/chargebee/v4/models/item/responses/ItemCreateResponse.java index 5a84d43d..9b0ab903 100644 --- a/src/main/java/com/chargebee/v4/models/item/responses/ItemCreateResponse.java +++ b/src/main/java/com/chargebee/v4/models/item/responses/ItemCreateResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** Immutable response object for ItemCreate operation. Contains the response data from the API. */ @@ -24,11 +25,12 @@ public static ItemCreateResponse fromJson(String json) { /** Parse JSON response into ItemCreateResponse object with HTTP response. */ public static ItemCreateResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __itemJson = JsonUtil.getObject(json, "item"); - if (__itemJson != null) { - builder.item(Item.fromJson(__itemJson)); + JsonObject __itemObj = JsonUtil.getJsonObject(jsonObj, "item"); + if (__itemObj != null) { + builder.item(Item.fromJson(__itemObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/item/responses/ItemDeleteResponse.java b/src/main/java/com/chargebee/v4/models/item/responses/ItemDeleteResponse.java index 63bd62e2..ea1273fd 100644 --- a/src/main/java/com/chargebee/v4/models/item/responses/ItemDeleteResponse.java +++ b/src/main/java/com/chargebee/v4/models/item/responses/ItemDeleteResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** Immutable response object for ItemDelete operation. Contains the response data from the API. */ @@ -24,11 +25,12 @@ public static ItemDeleteResponse fromJson(String json) { /** Parse JSON response into ItemDeleteResponse object with HTTP response. */ public static ItemDeleteResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __itemJson = JsonUtil.getObject(json, "item"); - if (__itemJson != null) { - builder.item(Item.fromJson(__itemJson)); + JsonObject __itemObj = JsonUtil.getJsonObject(jsonObj, "item"); + if (__itemObj != null) { + builder.item(Item.fromJson(__itemObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/item/responses/ItemListResponse.java b/src/main/java/com/chargebee/v4/models/item/responses/ItemListResponse.java index 99186b7e..e4dddf16 100644 --- a/src/main/java/com/chargebee/v4/models/item/responses/ItemListResponse.java +++ b/src/main/java/com/chargebee/v4/models/item/responses/ItemListResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.exceptions.ChargebeeException; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; import com.chargebee.v4.services.ItemService; import com.chargebee.v4.models.item.params.ItemListParams; @@ -43,13 +44,12 @@ private ItemListResponse( */ public static ItemListResponse fromJson(String json) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(ItemListItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "list"), ItemListItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new ItemListResponse(list, nextOffset, null, null, null); } catch (Exception e) { @@ -64,13 +64,12 @@ public static ItemListResponse fromJson(String json) { public static ItemListResponse fromJson( String json, ItemService service, ItemListParams originalParams, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(ItemListItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "list"), ItemListItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new ItemListResponse(list, nextOffset, service, originalParams, httpResponse); } catch (Exception e) { @@ -170,11 +169,15 @@ public Item getItem() { } public static ItemListItem fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static ItemListItem fromJson(JsonObject jsonObj) { ItemListItem item = new ItemListItem(); - String __itemJson = JsonUtil.getObject(json, "item"); - if (__itemJson != null) { - item.item = Item.fromJson(__itemJson); + JsonObject __itemObj = JsonUtil.getJsonObject(jsonObj, "item"); + if (__itemObj != null) { + item.item = Item.fromJson(__itemObj); } return item; diff --git a/src/main/java/com/chargebee/v4/models/item/responses/ItemRetrieveResponse.java b/src/main/java/com/chargebee/v4/models/item/responses/ItemRetrieveResponse.java index f9953c4a..2d49d0ad 100644 --- a/src/main/java/com/chargebee/v4/models/item/responses/ItemRetrieveResponse.java +++ b/src/main/java/com/chargebee/v4/models/item/responses/ItemRetrieveResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static ItemRetrieveResponse fromJson(String json) { /** Parse JSON response into ItemRetrieveResponse object with HTTP response. */ public static ItemRetrieveResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __itemJson = JsonUtil.getObject(json, "item"); - if (__itemJson != null) { - builder.item(Item.fromJson(__itemJson)); + JsonObject __itemObj = JsonUtil.getJsonObject(jsonObj, "item"); + if (__itemObj != null) { + builder.item(Item.fromJson(__itemObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/item/responses/ItemUpdateResponse.java b/src/main/java/com/chargebee/v4/models/item/responses/ItemUpdateResponse.java index 3da2eeef..5a989655 100644 --- a/src/main/java/com/chargebee/v4/models/item/responses/ItemUpdateResponse.java +++ b/src/main/java/com/chargebee/v4/models/item/responses/ItemUpdateResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** Immutable response object for ItemUpdate operation. Contains the response data from the API. */ @@ -24,11 +25,12 @@ public static ItemUpdateResponse fromJson(String json) { /** Parse JSON response into ItemUpdateResponse object with HTTP response. */ public static ItemUpdateResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __itemJson = JsonUtil.getObject(json, "item"); - if (__itemJson != null) { - builder.item(Item.fromJson(__itemJson)); + JsonObject __itemObj = JsonUtil.getJsonObject(jsonObj, "item"); + if (__itemObj != null) { + builder.item(Item.fromJson(__itemObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/itemEntitlement/ItemEntitlement.java b/src/main/java/com/chargebee/v4/models/itemEntitlement/ItemEntitlement.java index 57143ecd..2dc93a9e 100644 --- a/src/main/java/com/chargebee/v4/models/itemEntitlement/ItemEntitlement.java +++ b/src/main/java/com/chargebee/v4/models/itemEntitlement/ItemEntitlement.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.itemEntitlement; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; public class ItemEntitlement { @@ -82,21 +83,25 @@ public static ItemType fromString(String value) { } public static ItemEntitlement fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static ItemEntitlement fromJson(JsonObject jsonObj) { ItemEntitlement obj = new ItemEntitlement(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.itemId = JsonUtil.getString(json, "item_id"); + obj.itemId = JsonUtil.getString(jsonObj, "item_id"); - obj.itemType = ItemType.fromString(JsonUtil.getString(json, "item_type")); + obj.itemType = ItemType.fromString(JsonUtil.getString(jsonObj, "item_type")); - obj.featureId = JsonUtil.getString(json, "feature_id"); + obj.featureId = JsonUtil.getString(jsonObj, "feature_id"); - obj.featureName = JsonUtil.getString(json, "feature_name"); + obj.featureName = JsonUtil.getString(jsonObj, "feature_name"); - obj.value = JsonUtil.getString(json, "value"); + obj.value = JsonUtil.getString(jsonObj, "value"); - obj.name = JsonUtil.getString(json, "name"); + obj.name = JsonUtil.getString(jsonObj, "name"); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/itemEntitlement/responses/AddItemEntitlementsResponse.java b/src/main/java/com/chargebee/v4/models/itemEntitlement/responses/AddItemEntitlementsResponse.java index b4229c6a..e306e8c8 100644 --- a/src/main/java/com/chargebee/v4/models/itemEntitlement/responses/AddItemEntitlementsResponse.java +++ b/src/main/java/com/chargebee/v4/models/itemEntitlement/responses/AddItemEntitlementsResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static AddItemEntitlementsResponse fromJson(String json) { /** Parse JSON response into AddItemEntitlementsResponse object with HTTP response. */ public static AddItemEntitlementsResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __itemEntitlementJson = JsonUtil.getObject(json, "item_entitlement"); - if (__itemEntitlementJson != null) { - builder.itemEntitlement(ItemEntitlement.fromJson(__itemEntitlementJson)); + JsonObject __itemEntitlementObj = JsonUtil.getJsonObject(jsonObj, "item_entitlement"); + if (__itemEntitlementObj != null) { + builder.itemEntitlement(ItemEntitlement.fromJson(__itemEntitlementObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/itemEntitlement/responses/ItemEntitlementsForFeatureResponse.java b/src/main/java/com/chargebee/v4/models/itemEntitlement/responses/ItemEntitlementsForFeatureResponse.java index 070f7483..e3dc2b77 100644 --- a/src/main/java/com/chargebee/v4/models/itemEntitlement/responses/ItemEntitlementsForFeatureResponse.java +++ b/src/main/java/com/chargebee/v4/models/itemEntitlement/responses/ItemEntitlementsForFeatureResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.exceptions.ChargebeeException; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; import com.chargebee.v4.services.ItemEntitlementService; import com.chargebee.v4.models.itemEntitlement.params.ItemEntitlementsForFeatureParams; @@ -50,13 +51,14 @@ private ItemEntitlementsForFeatureResponse( */ public static ItemEntitlementsForFeatureResponse fromJson(String json) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(ItemEntitlementItemEntitlementsForFeatureItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "list"), + ItemEntitlementItemEntitlementsForFeatureItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new ItemEntitlementsForFeatureResponse(list, nextOffset, null, null, null, null); } catch (Exception e) { @@ -75,13 +77,14 @@ public static ItemEntitlementsForFeatureResponse fromJson( String featureId, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(ItemEntitlementItemEntitlementsForFeatureItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "list"), + ItemEntitlementItemEntitlementsForFeatureItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new ItemEntitlementsForFeatureResponse( list, nextOffset, featureId, service, originalParams, httpResponse); @@ -189,12 +192,16 @@ public ItemEntitlement getItemEntitlement() { } public static ItemEntitlementItemEntitlementsForFeatureItem fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static ItemEntitlementItemEntitlementsForFeatureItem fromJson(JsonObject jsonObj) { ItemEntitlementItemEntitlementsForFeatureItem item = new ItemEntitlementItemEntitlementsForFeatureItem(); - String __itemEntitlementJson = JsonUtil.getObject(json, "item_entitlement"); - if (__itemEntitlementJson != null) { - item.itemEntitlement = ItemEntitlement.fromJson(__itemEntitlementJson); + JsonObject __itemEntitlementObj = JsonUtil.getJsonObject(jsonObj, "item_entitlement"); + if (__itemEntitlementObj != null) { + item.itemEntitlement = ItemEntitlement.fromJson(__itemEntitlementObj); } return item; diff --git a/src/main/java/com/chargebee/v4/models/itemEntitlement/responses/ItemEntitlementsForItemResponse.java b/src/main/java/com/chargebee/v4/models/itemEntitlement/responses/ItemEntitlementsForItemResponse.java index 0f0d44c9..213291e5 100644 --- a/src/main/java/com/chargebee/v4/models/itemEntitlement/responses/ItemEntitlementsForItemResponse.java +++ b/src/main/java/com/chargebee/v4/models/itemEntitlement/responses/ItemEntitlementsForItemResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.exceptions.ChargebeeException; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; import com.chargebee.v4.services.ItemEntitlementService; import com.chargebee.v4.models.itemEntitlement.params.ItemEntitlementsForItemParams; @@ -50,13 +51,14 @@ private ItemEntitlementsForItemResponse( */ public static ItemEntitlementsForItemResponse fromJson(String json) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(ItemEntitlementItemEntitlementsForItemItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "list"), + ItemEntitlementItemEntitlementsForItemItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new ItemEntitlementsForItemResponse(list, nextOffset, null, null, null, null); } catch (Exception e) { @@ -75,13 +77,14 @@ public static ItemEntitlementsForItemResponse fromJson( String itemId, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(ItemEntitlementItemEntitlementsForItemItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "list"), + ItemEntitlementItemEntitlementsForItemItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new ItemEntitlementsForItemResponse( list, nextOffset, itemId, service, originalParams, httpResponse); @@ -184,12 +187,16 @@ public ItemEntitlement getItemEntitlement() { } public static ItemEntitlementItemEntitlementsForItemItem fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static ItemEntitlementItemEntitlementsForItemItem fromJson(JsonObject jsonObj) { ItemEntitlementItemEntitlementsForItemItem item = new ItemEntitlementItemEntitlementsForItemItem(); - String __itemEntitlementJson = JsonUtil.getObject(json, "item_entitlement"); - if (__itemEntitlementJson != null) { - item.itemEntitlement = ItemEntitlement.fromJson(__itemEntitlementJson); + JsonObject __itemEntitlementObj = JsonUtil.getJsonObject(jsonObj, "item_entitlement"); + if (__itemEntitlementObj != null) { + item.itemEntitlement = ItemEntitlement.fromJson(__itemEntitlementObj); } return item; diff --git a/src/main/java/com/chargebee/v4/models/itemEntitlement/responses/UpsertOrRemoveItemEntitlementsForItemResponse.java b/src/main/java/com/chargebee/v4/models/itemEntitlement/responses/UpsertOrRemoveItemEntitlementsForItemResponse.java index 3a796fee..bfb095b8 100644 --- a/src/main/java/com/chargebee/v4/models/itemEntitlement/responses/UpsertOrRemoveItemEntitlementsForItemResponse.java +++ b/src/main/java/com/chargebee/v4/models/itemEntitlement/responses/UpsertOrRemoveItemEntitlementsForItemResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -31,11 +32,12 @@ public static UpsertOrRemoveItemEntitlementsForItemResponse fromJson(String json public static UpsertOrRemoveItemEntitlementsForItemResponse fromJson( String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __itemEntitlementJson = JsonUtil.getObject(json, "item_entitlement"); - if (__itemEntitlementJson != null) { - builder.itemEntitlement(ItemEntitlement.fromJson(__itemEntitlementJson)); + JsonObject __itemEntitlementObj = JsonUtil.getJsonObject(jsonObj, "item_entitlement"); + if (__itemEntitlementObj != null) { + builder.itemEntitlement(ItemEntitlement.fromJson(__itemEntitlementObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/itemFamily/ItemFamily.java b/src/main/java/com/chargebee/v4/models/itemFamily/ItemFamily.java index d9b6b3af..082c550d 100644 --- a/src/main/java/com/chargebee/v4/models/itemFamily/ItemFamily.java +++ b/src/main/java/com/chargebee/v4/models/itemFamily/ItemFamily.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.itemFamily; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import java.sql.Timestamp; public class ItemFamily { @@ -139,9 +140,12 @@ public static Channel fromString(String value) { } public static ItemFamily fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static ItemFamily fromJson(JsonObject jsonObj) { ItemFamily obj = new ItemFamily(); - // Parse JSON to extract all keys for custom field extraction java.util.Set knownFields = new java.util.HashSet<>(); knownFields.add("id"); @@ -162,60 +166,29 @@ public static ItemFamily fromJson(String json) { knownFields.add("deleted"); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.name = JsonUtil.getString(json, "name"); + obj.name = JsonUtil.getString(jsonObj, "name"); - obj.description = JsonUtil.getString(json, "description"); + obj.description = JsonUtil.getString(jsonObj, "description"); - obj.status = Status.fromString(JsonUtil.getString(json, "status")); + obj.status = Status.fromString(JsonUtil.getString(jsonObj, "status")); - obj.resourceVersion = JsonUtil.getLong(json, "resource_version"); + obj.resourceVersion = JsonUtil.getLong(jsonObj, "resource_version"); - obj.updatedAt = JsonUtil.getTimestamp(json, "updated_at"); + obj.updatedAt = JsonUtil.getTimestamp(jsonObj, "updated_at"); - obj.channel = Channel.fromString(JsonUtil.getString(json, "channel")); + obj.channel = Channel.fromString(JsonUtil.getString(jsonObj, "channel")); - obj.businessEntityId = JsonUtil.getString(json, "business_entity_id"); + obj.businessEntityId = JsonUtil.getString(jsonObj, "business_entity_id"); - obj.deleted = JsonUtil.getBoolean(json, "deleted"); + obj.deleted = JsonUtil.getBoolean(jsonObj, "deleted"); - // Extract custom fields (fields starting with cf_) - obj.customFields = extractCustomFields(json, knownFields); + obj.customFields = JsonUtil.extractCustomFields(jsonObj, knownFields); return obj; } - /** - * Helper method to extract custom fields from JSON. Custom fields are fields that start with - * "cf_" and are not in the known fields set. - * - * @param json JSON string to parse - * @param knownFields set of known field names - * @return map of custom fields - */ - private static java.util.Map extractCustomFields( - String json, java.util.Set knownFields) { - java.util.Map customFields = new java.util.HashMap<>(); - try { - // Parse the entire JSON as a map - java.util.Map allFields = JsonUtil.parseJsonObjectToMap(json); - if (allFields != null) { - for (java.util.Map.Entry entry : allFields.entrySet()) { - String key = entry.getKey(); - // Include fields that start with "cf_" and are not in knownFields - if (key != null && key.startsWith("cf_") && !knownFields.contains(key)) { - customFields.put( - key, entry.getValue() != null ? String.valueOf(entry.getValue()) : null); - } - } - } - } catch (Exception e) { - // If parsing fails, return empty map - } - return customFields; - } - @Override public String toString() { return "ItemFamily{" diff --git a/src/main/java/com/chargebee/v4/models/itemFamily/responses/ItemFamilyCreateResponse.java b/src/main/java/com/chargebee/v4/models/itemFamily/responses/ItemFamilyCreateResponse.java index 82cc2991..475666ab 100644 --- a/src/main/java/com/chargebee/v4/models/itemFamily/responses/ItemFamilyCreateResponse.java +++ b/src/main/java/com/chargebee/v4/models/itemFamily/responses/ItemFamilyCreateResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static ItemFamilyCreateResponse fromJson(String json) { /** Parse JSON response into ItemFamilyCreateResponse object with HTTP response. */ public static ItemFamilyCreateResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __itemFamilyJson = JsonUtil.getObject(json, "item_family"); - if (__itemFamilyJson != null) { - builder.itemFamily(ItemFamily.fromJson(__itemFamilyJson)); + JsonObject __itemFamilyObj = JsonUtil.getJsonObject(jsonObj, "item_family"); + if (__itemFamilyObj != null) { + builder.itemFamily(ItemFamily.fromJson(__itemFamilyObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/itemFamily/responses/ItemFamilyDeleteResponse.java b/src/main/java/com/chargebee/v4/models/itemFamily/responses/ItemFamilyDeleteResponse.java index fb4767c0..c571209d 100644 --- a/src/main/java/com/chargebee/v4/models/itemFamily/responses/ItemFamilyDeleteResponse.java +++ b/src/main/java/com/chargebee/v4/models/itemFamily/responses/ItemFamilyDeleteResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static ItemFamilyDeleteResponse fromJson(String json) { /** Parse JSON response into ItemFamilyDeleteResponse object with HTTP response. */ public static ItemFamilyDeleteResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __itemFamilyJson = JsonUtil.getObject(json, "item_family"); - if (__itemFamilyJson != null) { - builder.itemFamily(ItemFamily.fromJson(__itemFamilyJson)); + JsonObject __itemFamilyObj = JsonUtil.getJsonObject(jsonObj, "item_family"); + if (__itemFamilyObj != null) { + builder.itemFamily(ItemFamily.fromJson(__itemFamilyObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/itemFamily/responses/ItemFamilyListResponse.java b/src/main/java/com/chargebee/v4/models/itemFamily/responses/ItemFamilyListResponse.java index 21096a67..de889788 100644 --- a/src/main/java/com/chargebee/v4/models/itemFamily/responses/ItemFamilyListResponse.java +++ b/src/main/java/com/chargebee/v4/models/itemFamily/responses/ItemFamilyListResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.exceptions.ChargebeeException; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; import com.chargebee.v4.services.ItemFamilyService; import com.chargebee.v4.models.itemFamily.params.ItemFamilyListParams; @@ -43,13 +44,12 @@ private ItemFamilyListResponse( */ public static ItemFamilyListResponse fromJson(String json) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(ItemFamilyListItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "list"), ItemFamilyListItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new ItemFamilyListResponse(list, nextOffset, null, null, null); } catch (Exception e) { @@ -67,13 +67,12 @@ public static ItemFamilyListResponse fromJson( ItemFamilyListParams originalParams, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(ItemFamilyListItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "list"), ItemFamilyListItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new ItemFamilyListResponse(list, nextOffset, service, originalParams, httpResponse); } catch (Exception e) { @@ -173,11 +172,15 @@ public ItemFamily getItemFamily() { } public static ItemFamilyListItem fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static ItemFamilyListItem fromJson(JsonObject jsonObj) { ItemFamilyListItem item = new ItemFamilyListItem(); - String __itemFamilyJson = JsonUtil.getObject(json, "item_family"); - if (__itemFamilyJson != null) { - item.itemFamily = ItemFamily.fromJson(__itemFamilyJson); + JsonObject __itemFamilyObj = JsonUtil.getJsonObject(jsonObj, "item_family"); + if (__itemFamilyObj != null) { + item.itemFamily = ItemFamily.fromJson(__itemFamilyObj); } return item; diff --git a/src/main/java/com/chargebee/v4/models/itemFamily/responses/ItemFamilyRetrieveResponse.java b/src/main/java/com/chargebee/v4/models/itemFamily/responses/ItemFamilyRetrieveResponse.java index f0f885bc..fc50d560 100644 --- a/src/main/java/com/chargebee/v4/models/itemFamily/responses/ItemFamilyRetrieveResponse.java +++ b/src/main/java/com/chargebee/v4/models/itemFamily/responses/ItemFamilyRetrieveResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static ItemFamilyRetrieveResponse fromJson(String json) { /** Parse JSON response into ItemFamilyRetrieveResponse object with HTTP response. */ public static ItemFamilyRetrieveResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __itemFamilyJson = JsonUtil.getObject(json, "item_family"); - if (__itemFamilyJson != null) { - builder.itemFamily(ItemFamily.fromJson(__itemFamilyJson)); + JsonObject __itemFamilyObj = JsonUtil.getJsonObject(jsonObj, "item_family"); + if (__itemFamilyObj != null) { + builder.itemFamily(ItemFamily.fromJson(__itemFamilyObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/itemFamily/responses/ItemFamilyUpdateResponse.java b/src/main/java/com/chargebee/v4/models/itemFamily/responses/ItemFamilyUpdateResponse.java index 6c03efc1..dd9719e6 100644 --- a/src/main/java/com/chargebee/v4/models/itemFamily/responses/ItemFamilyUpdateResponse.java +++ b/src/main/java/com/chargebee/v4/models/itemFamily/responses/ItemFamilyUpdateResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static ItemFamilyUpdateResponse fromJson(String json) { /** Parse JSON response into ItemFamilyUpdateResponse object with HTTP response. */ public static ItemFamilyUpdateResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __itemFamilyJson = JsonUtil.getObject(json, "item_family"); - if (__itemFamilyJson != null) { - builder.itemFamily(ItemFamily.fromJson(__itemFamilyJson)); + JsonObject __itemFamilyObj = JsonUtil.getJsonObject(jsonObj, "item_family"); + if (__itemFamilyObj != null) { + builder.itemFamily(ItemFamily.fromJson(__itemFamilyObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/itemPrice/ItemPrice.java b/src/main/java/com/chargebee/v4/models/itemPrice/ItemPrice.java index 43831982..384d5c3c 100644 --- a/src/main/java/com/chargebee/v4/models/itemPrice/ItemPrice.java +++ b/src/main/java/com/chargebee/v4/models/itemPrice/ItemPrice.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.itemPrice; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import java.sql.Timestamp; import java.util.List; @@ -561,9 +562,12 @@ public static ItemType fromString(String value) { } public static ItemPrice fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static ItemPrice fromJson(JsonObject jsonObj) { ItemPrice obj = new ItemPrice(); - // Parse JSON to extract all keys for custom field extraction java.util.Set knownFields = new java.util.HashSet<>(); knownFields.add("id"); @@ -652,147 +656,113 @@ public static ItemPrice fromJson(String json) { knownFields.add("accounting_detail"); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.name = JsonUtil.getString(json, "name"); + obj.name = JsonUtil.getString(jsonObj, "name"); - obj.itemFamilyId = JsonUtil.getString(json, "item_family_id"); + obj.itemFamilyId = JsonUtil.getString(jsonObj, "item_family_id"); - obj.itemId = JsonUtil.getString(json, "item_id"); + obj.itemId = JsonUtil.getString(jsonObj, "item_id"); - obj.description = JsonUtil.getString(json, "description"); + obj.description = JsonUtil.getString(jsonObj, "description"); - obj.status = Status.fromString(JsonUtil.getString(json, "status")); + obj.status = Status.fromString(JsonUtil.getString(jsonObj, "status")); - obj.externalName = JsonUtil.getString(json, "external_name"); + obj.externalName = JsonUtil.getString(jsonObj, "external_name"); - obj.priceVariantId = JsonUtil.getString(json, "price_variant_id"); + obj.priceVariantId = JsonUtil.getString(jsonObj, "price_variant_id"); - obj.prorationType = ProrationType.fromString(JsonUtil.getString(json, "proration_type")); + obj.prorationType = ProrationType.fromString(JsonUtil.getString(jsonObj, "proration_type")); - obj.pricingModel = PricingModel.fromString(JsonUtil.getString(json, "pricing_model")); + obj.pricingModel = PricingModel.fromString(JsonUtil.getString(jsonObj, "pricing_model")); - obj.price = JsonUtil.getLong(json, "price"); + obj.price = JsonUtil.getLong(jsonObj, "price"); - obj.priceInDecimal = JsonUtil.getString(json, "price_in_decimal"); + obj.priceInDecimal = JsonUtil.getString(jsonObj, "price_in_decimal"); - obj.period = JsonUtil.getInteger(json, "period"); + obj.period = JsonUtil.getInteger(jsonObj, "period"); - obj.currencyCode = JsonUtil.getString(json, "currency_code"); + obj.currencyCode = JsonUtil.getString(jsonObj, "currency_code"); - obj.periodUnit = PeriodUnit.fromString(JsonUtil.getString(json, "period_unit")); + obj.periodUnit = PeriodUnit.fromString(JsonUtil.getString(jsonObj, "period_unit")); - obj.trialPeriod = JsonUtil.getInteger(json, "trial_period"); + obj.trialPeriod = JsonUtil.getInteger(jsonObj, "trial_period"); - obj.trialPeriodUnit = TrialPeriodUnit.fromString(JsonUtil.getString(json, "trial_period_unit")); + obj.trialPeriodUnit = + TrialPeriodUnit.fromString(JsonUtil.getString(jsonObj, "trial_period_unit")); - obj.trialEndAction = TrialEndAction.fromString(JsonUtil.getString(json, "trial_end_action")); + obj.trialEndAction = TrialEndAction.fromString(JsonUtil.getString(jsonObj, "trial_end_action")); - obj.shippingPeriod = JsonUtil.getInteger(json, "shipping_period"); + obj.shippingPeriod = JsonUtil.getInteger(jsonObj, "shipping_period"); obj.shippingPeriodUnit = - ShippingPeriodUnit.fromString(JsonUtil.getString(json, "shipping_period_unit")); + ShippingPeriodUnit.fromString(JsonUtil.getString(jsonObj, "shipping_period_unit")); - obj.billingCycles = JsonUtil.getInteger(json, "billing_cycles"); + obj.billingCycles = JsonUtil.getInteger(jsonObj, "billing_cycles"); - obj.freeQuantity = JsonUtil.getInteger(json, "free_quantity"); + obj.freeQuantity = JsonUtil.getInteger(jsonObj, "free_quantity"); - obj.freeQuantityInDecimal = JsonUtil.getString(json, "free_quantity_in_decimal"); + obj.freeQuantityInDecimal = JsonUtil.getString(jsonObj, "free_quantity_in_decimal"); - obj.channel = Channel.fromString(JsonUtil.getString(json, "channel")); + obj.channel = Channel.fromString(JsonUtil.getString(jsonObj, "channel")); - obj.resourceVersion = JsonUtil.getLong(json, "resource_version"); + obj.resourceVersion = JsonUtil.getLong(jsonObj, "resource_version"); - obj.updatedAt = JsonUtil.getTimestamp(json, "updated_at"); + obj.updatedAt = JsonUtil.getTimestamp(jsonObj, "updated_at"); - obj.createdAt = JsonUtil.getTimestamp(json, "created_at"); + obj.createdAt = JsonUtil.getTimestamp(jsonObj, "created_at"); obj.usageAccumulationResetFrequency = UsageAccumulationResetFrequency.fromString( - JsonUtil.getString(json, "usage_accumulation_reset_frequency")); + JsonUtil.getString(jsonObj, "usage_accumulation_reset_frequency")); - obj.archivedAt = JsonUtil.getTimestamp(json, "archived_at"); + obj.archivedAt = JsonUtil.getTimestamp(jsonObj, "archived_at"); - obj.invoiceNotes = JsonUtil.getString(json, "invoice_notes"); + obj.invoiceNotes = JsonUtil.getString(jsonObj, "invoice_notes"); - obj.isTaxable = JsonUtil.getBoolean(json, "is_taxable"); + obj.isTaxable = JsonUtil.getBoolean(jsonObj, "is_taxable"); - String __metadataJson = JsonUtil.getObject(json, "metadata"); + JsonObject __metadataObj = JsonUtil.getJsonObject(jsonObj, "metadata"); obj.metadata = - __metadataJson != null - ? JsonUtil.parseJsonObjectToMap(__metadataJson) + __metadataObj != null + ? JsonUtil.parseJsonObjectToMap(__metadataObj) : new java.util.HashMap<>(); - obj.itemType = ItemType.fromString(JsonUtil.getString(json, "item_type")); + obj.itemType = ItemType.fromString(JsonUtil.getString(jsonObj, "item_type")); - obj.archivable = JsonUtil.getBoolean(json, "archivable"); + obj.archivable = JsonUtil.getBoolean(jsonObj, "archivable"); - obj.parentItemId = JsonUtil.getString(json, "parent_item_id"); + obj.parentItemId = JsonUtil.getString(jsonObj, "parent_item_id"); - obj.showDescriptionInInvoices = JsonUtil.getBoolean(json, "show_description_in_invoices"); + obj.showDescriptionInInvoices = JsonUtil.getBoolean(jsonObj, "show_description_in_invoices"); - obj.showDescriptionInQuotes = JsonUtil.getBoolean(json, "show_description_in_quotes"); + obj.showDescriptionInQuotes = JsonUtil.getBoolean(jsonObj, "show_description_in_quotes"); - obj.deleted = JsonUtil.getBoolean(json, "deleted"); + obj.deleted = JsonUtil.getBoolean(jsonObj, "deleted"); - obj.businessEntityId = JsonUtil.getString(json, "business_entity_id"); + obj.businessEntityId = JsonUtil.getString(jsonObj, "business_entity_id"); - obj.tiers = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "tiers")).stream() - .map(Tiers::fromJson) - .collect(java.util.stream.Collectors.toList()); + obj.tiers = JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "tiers"), Tiers::fromJson); - String __taxDetailJson = JsonUtil.getObject(json, "tax_detail"); - if (__taxDetailJson != null) { - obj.taxDetail = TaxDetail.fromJson(__taxDetailJson); + JsonObject __taxDetailObj = JsonUtil.getJsonObject(jsonObj, "tax_detail"); + if (__taxDetailObj != null) { + obj.taxDetail = TaxDetail.fromJson(__taxDetailObj); } obj.taxProvidersFields = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "tax_providers_fields")).stream() - .map(TaxProvidersFields::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "tax_providers_fields"), TaxProvidersFields::fromJson); - String __accountingDetailJson = JsonUtil.getObject(json, "accounting_detail"); - if (__accountingDetailJson != null) { - obj.accountingDetail = AccountingDetail.fromJson(__accountingDetailJson); + JsonObject __accountingDetailObj = JsonUtil.getJsonObject(jsonObj, "accounting_detail"); + if (__accountingDetailObj != null) { + obj.accountingDetail = AccountingDetail.fromJson(__accountingDetailObj); } - // Extract custom fields (fields starting with cf_) - obj.customFields = extractCustomFields(json, knownFields); + obj.customFields = JsonUtil.extractCustomFields(jsonObj, knownFields); return obj; } - /** - * Helper method to extract custom fields from JSON. Custom fields are fields that start with - * "cf_" and are not in the known fields set. - * - * @param json JSON string to parse - * @param knownFields set of known field names - * @return map of custom fields - */ - private static java.util.Map extractCustomFields( - String json, java.util.Set knownFields) { - java.util.Map customFields = new java.util.HashMap<>(); - try { - // Parse the entire JSON as a map - java.util.Map allFields = JsonUtil.parseJsonObjectToMap(json); - if (allFields != null) { - for (java.util.Map.Entry entry : allFields.entrySet()) { - String key = entry.getKey(); - // Include fields that start with "cf_" and are not in knownFields - if (key != null && key.startsWith("cf_") && !knownFields.contains(key)) { - customFields.put( - key, entry.getValue() != null ? String.valueOf(entry.getValue()) : null); - } - } - } - } catch (Exception e) { - // If parsing fails, return empty map - } - return customFields; - } - @Override public String toString() { return "ItemPrice{" @@ -1064,23 +1034,27 @@ public static PricingType fromString(String value) { } public static Tiers fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Tiers fromJson(JsonObject jsonObj) { Tiers obj = new Tiers(); - obj.startingUnit = JsonUtil.getInteger(json, "starting_unit"); + obj.startingUnit = JsonUtil.getInteger(jsonObj, "starting_unit"); - obj.endingUnit = JsonUtil.getInteger(json, "ending_unit"); + obj.endingUnit = JsonUtil.getInteger(jsonObj, "ending_unit"); - obj.price = JsonUtil.getLong(json, "price"); + obj.price = JsonUtil.getLong(jsonObj, "price"); - obj.startingUnitInDecimal = JsonUtil.getString(json, "starting_unit_in_decimal"); + obj.startingUnitInDecimal = JsonUtil.getString(jsonObj, "starting_unit_in_decimal"); - obj.endingUnitInDecimal = JsonUtil.getString(json, "ending_unit_in_decimal"); + obj.endingUnitInDecimal = JsonUtil.getString(jsonObj, "ending_unit_in_decimal"); - obj.priceInDecimal = JsonUtil.getString(json, "price_in_decimal"); + obj.priceInDecimal = JsonUtil.getString(jsonObj, "price_in_decimal"); - obj.pricingType = PricingType.fromString(JsonUtil.getString(json, "pricing_type")); + obj.pricingType = PricingType.fromString(JsonUtil.getString(jsonObj, "pricing_type")); - obj.packageSize = JsonUtil.getInteger(json, "package_size"); + obj.packageSize = JsonUtil.getInteger(jsonObj, "package_size"); return obj; } @@ -1209,22 +1183,26 @@ public static AvalaraSaleType fromString(String value) { } public static TaxDetail fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static TaxDetail fromJson(JsonObject jsonObj) { TaxDetail obj = new TaxDetail(); - obj.taxProfileId = JsonUtil.getString(json, "tax_profile_id"); + obj.taxProfileId = JsonUtil.getString(jsonObj, "tax_profile_id"); obj.avalaraSaleType = - AvalaraSaleType.fromString(JsonUtil.getString(json, "avalara_sale_type")); + AvalaraSaleType.fromString(JsonUtil.getString(jsonObj, "avalara_sale_type")); - obj.avalaraTransactionType = JsonUtil.getInteger(json, "avalara_transaction_type"); + obj.avalaraTransactionType = JsonUtil.getInteger(jsonObj, "avalara_transaction_type"); - obj.avalaraServiceType = JsonUtil.getInteger(json, "avalara_service_type"); + obj.avalaraServiceType = JsonUtil.getInteger(jsonObj, "avalara_service_type"); - obj.avalaraTaxCode = JsonUtil.getString(json, "avalara_tax_code"); + obj.avalaraTaxCode = JsonUtil.getString(jsonObj, "avalara_tax_code"); - obj.hsnCode = JsonUtil.getString(json, "hsn_code"); + obj.hsnCode = JsonUtil.getString(jsonObj, "hsn_code"); - obj.taxjarProductCode = JsonUtil.getString(json, "taxjar_product_code"); + obj.taxjarProductCode = JsonUtil.getString(jsonObj, "taxjar_product_code"); return obj; } @@ -1297,13 +1275,17 @@ public String getFieldValue() { } public static TaxProvidersFields fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static TaxProvidersFields fromJson(JsonObject jsonObj) { TaxProvidersFields obj = new TaxProvidersFields(); - obj.providerName = JsonUtil.getString(json, "provider_name"); + obj.providerName = JsonUtil.getString(jsonObj, "provider_name"); - obj.fieldId = JsonUtil.getString(json, "field_id"); + obj.fieldId = JsonUtil.getString(jsonObj, "field_id"); - obj.fieldValue = JsonUtil.getString(json, "field_value"); + obj.fieldValue = JsonUtil.getString(jsonObj, "field_value"); return obj; } @@ -1372,19 +1354,23 @@ public String getAccountingCategory4() { } public static AccountingDetail fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static AccountingDetail fromJson(JsonObject jsonObj) { AccountingDetail obj = new AccountingDetail(); - obj.sku = JsonUtil.getString(json, "sku"); + obj.sku = JsonUtil.getString(jsonObj, "sku"); - obj.accountingCode = JsonUtil.getString(json, "accounting_code"); + obj.accountingCode = JsonUtil.getString(jsonObj, "accounting_code"); - obj.accountingCategory1 = JsonUtil.getString(json, "accounting_category1"); + obj.accountingCategory1 = JsonUtil.getString(jsonObj, "accounting_category1"); - obj.accountingCategory2 = JsonUtil.getString(json, "accounting_category2"); + obj.accountingCategory2 = JsonUtil.getString(jsonObj, "accounting_category2"); - obj.accountingCategory3 = JsonUtil.getString(json, "accounting_category3"); + obj.accountingCategory3 = JsonUtil.getString(jsonObj, "accounting_category3"); - obj.accountingCategory4 = JsonUtil.getString(json, "accounting_category4"); + obj.accountingCategory4 = JsonUtil.getString(jsonObj, "accounting_category4"); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/itemPrice/responses/FindApplicableItemPricesResponse.java b/src/main/java/com/chargebee/v4/models/itemPrice/responses/FindApplicableItemPricesResponse.java index 95797f1a..fbdd4b95 100644 --- a/src/main/java/com/chargebee/v4/models/itemPrice/responses/FindApplicableItemPricesResponse.java +++ b/src/main/java/com/chargebee/v4/models/itemPrice/responses/FindApplicableItemPricesResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.exceptions.ChargebeeException; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; import com.chargebee.v4.services.ItemPriceService; import com.chargebee.v4.models.itemPrice.params.FindApplicableItemPricesParams; @@ -50,13 +51,14 @@ private FindApplicableItemPricesResponse( */ public static FindApplicableItemPricesResponse fromJson(String json) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(ItemPriceFindApplicableItemPricesItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "list"), + ItemPriceFindApplicableItemPricesItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new FindApplicableItemPricesResponse(list, nextOffset, null, null, null, null); } catch (Exception e) { @@ -75,13 +77,14 @@ public static FindApplicableItemPricesResponse fromJson( String itemPriceId, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(ItemPriceFindApplicableItemPricesItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "list"), + ItemPriceFindApplicableItemPricesItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new FindApplicableItemPricesResponse( list, nextOffset, itemPriceId, service, originalParams, httpResponse); @@ -189,11 +192,15 @@ public ItemPrice getItemPrice() { } public static ItemPriceFindApplicableItemPricesItem fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static ItemPriceFindApplicableItemPricesItem fromJson(JsonObject jsonObj) { ItemPriceFindApplicableItemPricesItem item = new ItemPriceFindApplicableItemPricesItem(); - String __itemPriceJson = JsonUtil.getObject(json, "item_price"); - if (__itemPriceJson != null) { - item.itemPrice = ItemPrice.fromJson(__itemPriceJson); + JsonObject __itemPriceObj = JsonUtil.getJsonObject(jsonObj, "item_price"); + if (__itemPriceObj != null) { + item.itemPrice = ItemPrice.fromJson(__itemPriceObj); } return item; diff --git a/src/main/java/com/chargebee/v4/models/itemPrice/responses/ItemPriceCreateResponse.java b/src/main/java/com/chargebee/v4/models/itemPrice/responses/ItemPriceCreateResponse.java index 3e01f682..057f7661 100644 --- a/src/main/java/com/chargebee/v4/models/itemPrice/responses/ItemPriceCreateResponse.java +++ b/src/main/java/com/chargebee/v4/models/itemPrice/responses/ItemPriceCreateResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -26,11 +27,12 @@ public static ItemPriceCreateResponse fromJson(String json) { /** Parse JSON response into ItemPriceCreateResponse object with HTTP response. */ public static ItemPriceCreateResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __itemPriceJson = JsonUtil.getObject(json, "item_price"); - if (__itemPriceJson != null) { - builder.itemPrice(ItemPrice.fromJson(__itemPriceJson)); + JsonObject __itemPriceObj = JsonUtil.getJsonObject(jsonObj, "item_price"); + if (__itemPriceObj != null) { + builder.itemPrice(ItemPrice.fromJson(__itemPriceObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/itemPrice/responses/ItemPriceDeleteResponse.java b/src/main/java/com/chargebee/v4/models/itemPrice/responses/ItemPriceDeleteResponse.java index 251fbe10..55618faa 100644 --- a/src/main/java/com/chargebee/v4/models/itemPrice/responses/ItemPriceDeleteResponse.java +++ b/src/main/java/com/chargebee/v4/models/itemPrice/responses/ItemPriceDeleteResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -26,11 +27,12 @@ public static ItemPriceDeleteResponse fromJson(String json) { /** Parse JSON response into ItemPriceDeleteResponse object with HTTP response. */ public static ItemPriceDeleteResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __itemPriceJson = JsonUtil.getObject(json, "item_price"); - if (__itemPriceJson != null) { - builder.itemPrice(ItemPrice.fromJson(__itemPriceJson)); + JsonObject __itemPriceObj = JsonUtil.getJsonObject(jsonObj, "item_price"); + if (__itemPriceObj != null) { + builder.itemPrice(ItemPrice.fromJson(__itemPriceObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/itemPrice/responses/ItemPriceFindApplicableItemsResponse.java b/src/main/java/com/chargebee/v4/models/itemPrice/responses/ItemPriceFindApplicableItemsResponse.java index dfec34ef..9a5bfb49 100644 --- a/src/main/java/com/chargebee/v4/models/itemPrice/responses/ItemPriceFindApplicableItemsResponse.java +++ b/src/main/java/com/chargebee/v4/models/itemPrice/responses/ItemPriceFindApplicableItemsResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.exceptions.ChargebeeException; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; import com.chargebee.v4.services.ItemPriceService; import com.chargebee.v4.models.itemPrice.params.ItemPriceFindApplicableItemsParams; @@ -51,13 +52,13 @@ private ItemPriceFindApplicableItemsResponse( */ public static ItemPriceFindApplicableItemsResponse fromJson(String json) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(ItemPriceFindApplicableItemsItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "list"), ItemPriceFindApplicableItemsItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new ItemPriceFindApplicableItemsResponse(list, nextOffset, null, null, null, null); } catch (Exception e) { @@ -77,13 +78,13 @@ public static ItemPriceFindApplicableItemsResponse fromJson( String itemPriceId, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(ItemPriceFindApplicableItemsItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "list"), ItemPriceFindApplicableItemsItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new ItemPriceFindApplicableItemsResponse( list, nextOffset, itemPriceId, service, originalParams, httpResponse); @@ -192,11 +193,15 @@ public Item getItem() { } public static ItemPriceFindApplicableItemsItem fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static ItemPriceFindApplicableItemsItem fromJson(JsonObject jsonObj) { ItemPriceFindApplicableItemsItem item = new ItemPriceFindApplicableItemsItem(); - String __itemJson = JsonUtil.getObject(json, "item"); - if (__itemJson != null) { - item.item = Item.fromJson(__itemJson); + JsonObject __itemObj = JsonUtil.getJsonObject(jsonObj, "item"); + if (__itemObj != null) { + item.item = Item.fromJson(__itemObj); } return item; diff --git a/src/main/java/com/chargebee/v4/models/itemPrice/responses/ItemPriceListResponse.java b/src/main/java/com/chargebee/v4/models/itemPrice/responses/ItemPriceListResponse.java index bcc9ff7f..2dcd8362 100644 --- a/src/main/java/com/chargebee/v4/models/itemPrice/responses/ItemPriceListResponse.java +++ b/src/main/java/com/chargebee/v4/models/itemPrice/responses/ItemPriceListResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.exceptions.ChargebeeException; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; import com.chargebee.v4.services.ItemPriceService; import com.chargebee.v4.models.itemPrice.params.ItemPriceListParams; @@ -43,13 +44,12 @@ private ItemPriceListResponse( */ public static ItemPriceListResponse fromJson(String json) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(ItemPriceListItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "list"), ItemPriceListItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new ItemPriceListResponse(list, nextOffset, null, null, null); } catch (Exception e) { @@ -67,13 +67,12 @@ public static ItemPriceListResponse fromJson( ItemPriceListParams originalParams, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(ItemPriceListItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "list"), ItemPriceListItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new ItemPriceListResponse(list, nextOffset, service, originalParams, httpResponse); } catch (Exception e) { @@ -173,11 +172,15 @@ public ItemPrice getItemPrice() { } public static ItemPriceListItem fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static ItemPriceListItem fromJson(JsonObject jsonObj) { ItemPriceListItem item = new ItemPriceListItem(); - String __itemPriceJson = JsonUtil.getObject(json, "item_price"); - if (__itemPriceJson != null) { - item.itemPrice = ItemPrice.fromJson(__itemPriceJson); + JsonObject __itemPriceObj = JsonUtil.getJsonObject(jsonObj, "item_price"); + if (__itemPriceObj != null) { + item.itemPrice = ItemPrice.fromJson(__itemPriceObj); } return item; diff --git a/src/main/java/com/chargebee/v4/models/itemPrice/responses/ItemPriceRetrieveResponse.java b/src/main/java/com/chargebee/v4/models/itemPrice/responses/ItemPriceRetrieveResponse.java index 03ce0c8d..9daf982f 100644 --- a/src/main/java/com/chargebee/v4/models/itemPrice/responses/ItemPriceRetrieveResponse.java +++ b/src/main/java/com/chargebee/v4/models/itemPrice/responses/ItemPriceRetrieveResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static ItemPriceRetrieveResponse fromJson(String json) { /** Parse JSON response into ItemPriceRetrieveResponse object with HTTP response. */ public static ItemPriceRetrieveResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __itemPriceJson = JsonUtil.getObject(json, "item_price"); - if (__itemPriceJson != null) { - builder.itemPrice(ItemPrice.fromJson(__itemPriceJson)); + JsonObject __itemPriceObj = JsonUtil.getJsonObject(jsonObj, "item_price"); + if (__itemPriceObj != null) { + builder.itemPrice(ItemPrice.fromJson(__itemPriceObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/itemPrice/responses/ItemPriceUpdateResponse.java b/src/main/java/com/chargebee/v4/models/itemPrice/responses/ItemPriceUpdateResponse.java index 00a9d9ff..b35f07f2 100644 --- a/src/main/java/com/chargebee/v4/models/itemPrice/responses/ItemPriceUpdateResponse.java +++ b/src/main/java/com/chargebee/v4/models/itemPrice/responses/ItemPriceUpdateResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -26,11 +27,12 @@ public static ItemPriceUpdateResponse fromJson(String json) { /** Parse JSON response into ItemPriceUpdateResponse object with HTTP response. */ public static ItemPriceUpdateResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __itemPriceJson = JsonUtil.getObject(json, "item_price"); - if (__itemPriceJson != null) { - builder.itemPrice(ItemPrice.fromJson(__itemPriceJson)); + JsonObject __itemPriceObj = JsonUtil.getJsonObject(jsonObj, "item_price"); + if (__itemPriceObj != null) { + builder.itemPrice(ItemPrice.fromJson(__itemPriceObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/media/Media.java b/src/main/java/com/chargebee/v4/models/media/Media.java index 7828d110..31eea9fa 100644 --- a/src/main/java/com/chargebee/v4/models/media/Media.java +++ b/src/main/java/com/chargebee/v4/models/media/Media.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.media; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; public class Media { @@ -33,15 +34,19 @@ public String getMediaType() { } public static Media fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Media fromJson(JsonObject jsonObj) { Media obj = new Media(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.url = JsonUtil.getString(json, "url"); + obj.url = JsonUtil.getString(jsonObj, "url"); - obj.altText = JsonUtil.getString(json, "alt_text"); + obj.altText = JsonUtil.getString(jsonObj, "alt_text"); - obj.mediaType = JsonUtil.getString(json, "media_type"); + obj.mediaType = JsonUtil.getString(jsonObj, "media_type"); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/media/responses/CreateMediaAndAttachToItemResponse.java b/src/main/java/com/chargebee/v4/models/media/responses/CreateMediaAndAttachToItemResponse.java index 3bd37fa1..b8df5040 100644 --- a/src/main/java/com/chargebee/v4/models/media/responses/CreateMediaAndAttachToItemResponse.java +++ b/src/main/java/com/chargebee/v4/models/media/responses/CreateMediaAndAttachToItemResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static CreateMediaAndAttachToItemResponse fromJson(String json) { /** Parse JSON response into CreateMediaAndAttachToItemResponse object with HTTP response. */ public static CreateMediaAndAttachToItemResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __mediaJson = JsonUtil.getObject(json, "media"); - if (__mediaJson != null) { - builder.media(Media.fromJson(__mediaJson)); + JsonObject __mediaObj = JsonUtil.getJsonObject(jsonObj, "media"); + if (__mediaObj != null) { + builder.media(Media.fromJson(__mediaObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/metadata/Metadata.java b/src/main/java/com/chargebee/v4/models/metadata/Metadata.java index f9702e75..7edcc853 100644 --- a/src/main/java/com/chargebee/v4/models/metadata/Metadata.java +++ b/src/main/java/com/chargebee/v4/models/metadata/Metadata.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.metadata; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; public class Metadata { @@ -18,9 +19,13 @@ public String getChangeType() { } public static Metadata fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Metadata fromJson(JsonObject jsonObj) { Metadata obj = new Metadata(); - obj.changeType = JsonUtil.getString(json, "change_type"); + obj.changeType = JsonUtil.getString(jsonObj, "change_type"); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/nonSubscription/NonSubscription.java b/src/main/java/com/chargebee/v4/models/nonSubscription/NonSubscription.java index e668e505..14f3afcf 100644 --- a/src/main/java/com/chargebee/v4/models/nonSubscription/NonSubscription.java +++ b/src/main/java/com/chargebee/v4/models/nonSubscription/NonSubscription.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.nonSubscription; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; public class NonSubscription { @@ -34,15 +35,19 @@ public String getChargeId() { } public static NonSubscription fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static NonSubscription fromJson(JsonObject jsonObj) { NonSubscription obj = new NonSubscription(); - obj.appId = JsonUtil.getString(json, "app_id"); + obj.appId = JsonUtil.getString(jsonObj, "app_id"); - obj.invoiceId = JsonUtil.getString(json, "invoice_id"); + obj.invoiceId = JsonUtil.getString(jsonObj, "invoice_id"); - obj.customerId = JsonUtil.getString(json, "customer_id"); + obj.customerId = JsonUtil.getString(jsonObj, "customer_id"); - obj.chargeId = JsonUtil.getString(json, "charge_id"); + obj.chargeId = JsonUtil.getString(jsonObj, "charge_id"); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/nonSubscription/responses/NonSubscriptionProcessReceiptResponse.java b/src/main/java/com/chargebee/v4/models/nonSubscription/responses/NonSubscriptionProcessReceiptResponse.java index 96a95153..71201dca 100644 --- a/src/main/java/com/chargebee/v4/models/nonSubscription/responses/NonSubscriptionProcessReceiptResponse.java +++ b/src/main/java/com/chargebee/v4/models/nonSubscription/responses/NonSubscriptionProcessReceiptResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static NonSubscriptionProcessReceiptResponse fromJson(String json) { /** Parse JSON response into NonSubscriptionProcessReceiptResponse object with HTTP response. */ public static NonSubscriptionProcessReceiptResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __nonSubscriptionJson = JsonUtil.getObject(json, "non_subscription"); - if (__nonSubscriptionJson != null) { - builder.nonSubscription(NonSubscription.fromJson(__nonSubscriptionJson)); + JsonObject __nonSubscriptionObj = JsonUtil.getJsonObject(jsonObj, "non_subscription"); + if (__nonSubscriptionObj != null) { + builder.nonSubscription(NonSubscription.fromJson(__nonSubscriptionObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/offerEvent/responses/OfferEventsResponse.java b/src/main/java/com/chargebee/v4/models/offerEvent/responses/OfferEventsResponse.java index f40bc52f..3919a7fb 100644 --- a/src/main/java/com/chargebee/v4/models/offerEvent/responses/OfferEventsResponse.java +++ b/src/main/java/com/chargebee/v4/models/offerEvent/responses/OfferEventsResponse.java @@ -1,6 +1,8 @@ package com.chargebee.v4.models.offerEvent.responses; import com.chargebee.v4.models.BaseResponse; +import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** Immutable response object for OfferEvents operation. Contains the response data from the API. */ @@ -18,6 +20,7 @@ public static OfferEventsResponse fromJson(String json) { /** Parse JSON response into OfferEventsResponse object with HTTP response. */ public static OfferEventsResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/offerFulfillment/OfferFulfillment.java b/src/main/java/com/chargebee/v4/models/offerFulfillment/OfferFulfillment.java index 3daf4293..7943a790 100644 --- a/src/main/java/com/chargebee/v4/models/offerFulfillment/OfferFulfillment.java +++ b/src/main/java/com/chargebee/v4/models/offerFulfillment/OfferFulfillment.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.offerFulfillment; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import java.sql.Timestamp; public class OfferFulfillment { @@ -128,29 +129,33 @@ public static Status fromString(String value) { } public static OfferFulfillment fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static OfferFulfillment fromJson(JsonObject jsonObj) { OfferFulfillment obj = new OfferFulfillment(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.personalizedOfferId = JsonUtil.getString(json, "personalized_offer_id"); + obj.personalizedOfferId = JsonUtil.getString(jsonObj, "personalized_offer_id"); - obj.optionId = JsonUtil.getString(json, "option_id"); + obj.optionId = JsonUtil.getString(jsonObj, "option_id"); - obj.processingType = ProcessingType.fromString(JsonUtil.getString(json, "processing_type")); + obj.processingType = ProcessingType.fromString(JsonUtil.getString(jsonObj, "processing_type")); - obj.status = Status.fromString(JsonUtil.getString(json, "status")); + obj.status = Status.fromString(JsonUtil.getString(jsonObj, "status")); - obj.redirectUrl = JsonUtil.getString(json, "redirect_url"); + obj.redirectUrl = JsonUtil.getString(jsonObj, "redirect_url"); - obj.failedAt = JsonUtil.getTimestamp(json, "failed_at"); + obj.failedAt = JsonUtil.getTimestamp(jsonObj, "failed_at"); - obj.createdAt = JsonUtil.getTimestamp(json, "created_at"); + obj.createdAt = JsonUtil.getTimestamp(jsonObj, "created_at"); - obj.completedAt = JsonUtil.getTimestamp(json, "completed_at"); + obj.completedAt = JsonUtil.getTimestamp(jsonObj, "completed_at"); - String __errorJson = JsonUtil.getObject(json, "error"); - if (__errorJson != null) { - obj.error = Error.fromJson(__errorJson); + JsonObject __errorObj = JsonUtil.getJsonObject(jsonObj, "error"); + if (__errorObj != null) { + obj.error = Error.fromJson(__errorObj); } return obj; @@ -264,11 +269,15 @@ public static Code fromString(String value) { } public static Error fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Error fromJson(JsonObject jsonObj) { Error obj = new Error(); - obj.code = Code.fromString(JsonUtil.getString(json, "code")); + obj.code = Code.fromString(JsonUtil.getString(jsonObj, "code")); - obj.message = JsonUtil.getString(json, "message"); + obj.message = JsonUtil.getString(jsonObj, "message"); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/offerFulfillment/responses/OfferFulfillmentsGetResponse.java b/src/main/java/com/chargebee/v4/models/offerFulfillment/responses/OfferFulfillmentsGetResponse.java index 92fc1b6b..f88f2844 100644 --- a/src/main/java/com/chargebee/v4/models/offerFulfillment/responses/OfferFulfillmentsGetResponse.java +++ b/src/main/java/com/chargebee/v4/models/offerFulfillment/responses/OfferFulfillmentsGetResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static OfferFulfillmentsGetResponse fromJson(String json) { /** Parse JSON response into OfferFulfillmentsGetResponse object with HTTP response. */ public static OfferFulfillmentsGetResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __offerFulfillmentJson = JsonUtil.getObject(json, "offer_fulfillment"); - if (__offerFulfillmentJson != null) { - builder.offerFulfillment(OfferFulfillment.fromJson(__offerFulfillmentJson)); + JsonObject __offerFulfillmentObj = JsonUtil.getJsonObject(jsonObj, "offer_fulfillment"); + if (__offerFulfillmentObj != null) { + builder.offerFulfillment(OfferFulfillment.fromJson(__offerFulfillmentObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/offerFulfillment/responses/OfferFulfillmentsResponse.java b/src/main/java/com/chargebee/v4/models/offerFulfillment/responses/OfferFulfillmentsResponse.java index 8ea4e7d1..ebb17deb 100644 --- a/src/main/java/com/chargebee/v4/models/offerFulfillment/responses/OfferFulfillmentsResponse.java +++ b/src/main/java/com/chargebee/v4/models/offerFulfillment/responses/OfferFulfillmentsResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -33,16 +34,17 @@ public static OfferFulfillmentsResponse fromJson(String json) { /** Parse JSON response into OfferFulfillmentsResponse object with HTTP response. */ public static OfferFulfillmentsResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __offerFulfillmentJson = JsonUtil.getObject(json, "offer_fulfillment"); - if (__offerFulfillmentJson != null) { - builder.offerFulfillment(OfferFulfillment.fromJson(__offerFulfillmentJson)); + JsonObject __offerFulfillmentObj = JsonUtil.getJsonObject(jsonObj, "offer_fulfillment"); + if (__offerFulfillmentObj != null) { + builder.offerFulfillment(OfferFulfillment.fromJson(__offerFulfillmentObj)); } - String __hostedPageJson = JsonUtil.getObject(json, "hosted_page"); - if (__hostedPageJson != null) { - builder.hostedPage(HostedPage.fromJson(__hostedPageJson)); + JsonObject __hostedPageObj = JsonUtil.getJsonObject(jsonObj, "hosted_page"); + if (__hostedPageObj != null) { + builder.hostedPage(HostedPage.fromJson(__hostedPageObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/offerFulfillment/responses/OfferFulfillmentsUpdateResponse.java b/src/main/java/com/chargebee/v4/models/offerFulfillment/responses/OfferFulfillmentsUpdateResponse.java index 4ac21907..59072e80 100644 --- a/src/main/java/com/chargebee/v4/models/offerFulfillment/responses/OfferFulfillmentsUpdateResponse.java +++ b/src/main/java/com/chargebee/v4/models/offerFulfillment/responses/OfferFulfillmentsUpdateResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static OfferFulfillmentsUpdateResponse fromJson(String json) { /** Parse JSON response into OfferFulfillmentsUpdateResponse object with HTTP response. */ public static OfferFulfillmentsUpdateResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __offerFulfillmentJson = JsonUtil.getObject(json, "offer_fulfillment"); - if (__offerFulfillmentJson != null) { - builder.offerFulfillment(OfferFulfillment.fromJson(__offerFulfillmentJson)); + JsonObject __offerFulfillmentObj = JsonUtil.getJsonObject(jsonObj, "offer_fulfillment"); + if (__offerFulfillmentObj != null) { + builder.offerFulfillment(OfferFulfillment.fromJson(__offerFulfillmentObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/omnichannelOneTimeOrder/OmnichannelOneTimeOrder.java b/src/main/java/com/chargebee/v4/models/omnichannelOneTimeOrder/OmnichannelOneTimeOrder.java index 8ec536e7..44874ed0 100644 --- a/src/main/java/com/chargebee/v4/models/omnichannelOneTimeOrder/OmnichannelOneTimeOrder.java +++ b/src/main/java/com/chargebee/v4/models/omnichannelOneTimeOrder/OmnichannelOneTimeOrder.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.omnichannelOneTimeOrder; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import java.sql.Timestamp; import java.util.List; @@ -93,33 +94,36 @@ public static Source fromString(String value) { } public static OmnichannelOneTimeOrder fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static OmnichannelOneTimeOrder fromJson(JsonObject jsonObj) { OmnichannelOneTimeOrder obj = new OmnichannelOneTimeOrder(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.appId = JsonUtil.getString(json, "app_id"); + obj.appId = JsonUtil.getString(jsonObj, "app_id"); - obj.customerId = JsonUtil.getString(json, "customer_id"); + obj.customerId = JsonUtil.getString(jsonObj, "customer_id"); - obj.idAtSource = JsonUtil.getString(json, "id_at_source"); + obj.idAtSource = JsonUtil.getString(jsonObj, "id_at_source"); - obj.origin = JsonUtil.getString(json, "origin"); + obj.origin = JsonUtil.getString(jsonObj, "origin"); - obj.source = Source.fromString(JsonUtil.getString(json, "source")); + obj.source = Source.fromString(JsonUtil.getString(jsonObj, "source")); - obj.createdAt = JsonUtil.getTimestamp(json, "created_at"); + obj.createdAt = JsonUtil.getTimestamp(jsonObj, "created_at"); - obj.resourceVersion = JsonUtil.getLong(json, "resource_version"); + obj.resourceVersion = JsonUtil.getLong(jsonObj, "resource_version"); obj.omnichannelOneTimeOrderItems = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "omnichannel_one_time_order_items")) - .stream() - .map(OmnichannelOneTimeOrderItems::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "omnichannel_one_time_order_items"), + OmnichannelOneTimeOrderItems::fromJson); - String __purchaseTransactionJson = JsonUtil.getObject(json, "purchase_transaction"); - if (__purchaseTransactionJson != null) { - obj.purchaseTransaction = PurchaseTransaction.fromJson(__purchaseTransactionJson); + JsonObject __purchaseTransactionObj = JsonUtil.getJsonObject(jsonObj, "purchase_transaction"); + if (__purchaseTransactionObj != null) { + obj.purchaseTransaction = PurchaseTransaction.fromJson(__purchaseTransactionObj); } return obj; @@ -265,24 +269,28 @@ public static CancellationReason fromString(String value) { } public static OmnichannelOneTimeOrderItems fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static OmnichannelOneTimeOrderItems fromJson(JsonObject jsonObj) { OmnichannelOneTimeOrderItems obj = new OmnichannelOneTimeOrderItems(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.itemIdAtSource = JsonUtil.getString(json, "item_id_at_source"); + obj.itemIdAtSource = JsonUtil.getString(jsonObj, "item_id_at_source"); - obj.itemTypeAtSource = JsonUtil.getString(json, "item_type_at_source"); + obj.itemTypeAtSource = JsonUtil.getString(jsonObj, "item_type_at_source"); - obj.quantity = JsonUtil.getInteger(json, "quantity"); + obj.quantity = JsonUtil.getInteger(jsonObj, "quantity"); - obj.cancelledAt = JsonUtil.getTimestamp(json, "cancelled_at"); + obj.cancelledAt = JsonUtil.getTimestamp(jsonObj, "cancelled_at"); obj.cancellationReason = - CancellationReason.fromString(JsonUtil.getString(json, "cancellation_reason")); + CancellationReason.fromString(JsonUtil.getString(jsonObj, "cancellation_reason")); - obj.createdAt = JsonUtil.getTimestamp(json, "created_at"); + obj.createdAt = JsonUtil.getTimestamp(jsonObj, "created_at"); - obj.resourceVersion = JsonUtil.getLong(json, "resource_version"); + obj.resourceVersion = JsonUtil.getLong(jsonObj, "resource_version"); return obj; } @@ -432,39 +440,41 @@ public static Type fromString(String value) { } public static PurchaseTransaction fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static PurchaseTransaction fromJson(JsonObject jsonObj) { PurchaseTransaction obj = new PurchaseTransaction(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.idAtSource = JsonUtil.getString(json, "id_at_source"); + obj.idAtSource = JsonUtil.getString(jsonObj, "id_at_source"); - obj.appId = JsonUtil.getString(json, "app_id"); + obj.appId = JsonUtil.getString(jsonObj, "app_id"); - obj.priceCurrency = JsonUtil.getString(json, "price_currency"); + obj.priceCurrency = JsonUtil.getString(jsonObj, "price_currency"); - obj.priceUnits = JsonUtil.getLong(json, "price_units"); + obj.priceUnits = JsonUtil.getLong(jsonObj, "price_units"); - obj.priceNanos = JsonUtil.getLong(json, "price_nanos"); + obj.priceNanos = JsonUtil.getLong(jsonObj, "price_nanos"); - obj.type = Type.fromString(JsonUtil.getString(json, "type")); + obj.type = Type.fromString(JsonUtil.getString(jsonObj, "type")); - obj.transactedAt = JsonUtil.getTimestamp(json, "transacted_at"); + obj.transactedAt = JsonUtil.getTimestamp(jsonObj, "transacted_at"); - obj.createdAt = JsonUtil.getTimestamp(json, "created_at"); + obj.createdAt = JsonUtil.getTimestamp(jsonObj, "created_at"); - obj.resourceVersion = JsonUtil.getLong(json, "resource_version"); + obj.resourceVersion = JsonUtil.getLong(jsonObj, "resource_version"); obj.linkedOmnichannelSubscriptions = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "linked_omnichannel_subscriptions")) - .stream() - .map(LinkedOmnichannelSubscriptions::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "linked_omnichannel_subscriptions"), + LinkedOmnichannelSubscriptions::fromJson); obj.linkedOmnichannelOneTimeOrders = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "linked_omnichannel_one_time_orders")) - .stream() - .map(LinkedOmnichannelOneTimeOrders::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "linked_omnichannel_one_time_orders"), + LinkedOmnichannelOneTimeOrders::fromJson); return obj; } @@ -548,9 +558,13 @@ public String getOmnichannelSubscriptionId() { } public static LinkedOmnichannelSubscriptions fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static LinkedOmnichannelSubscriptions fromJson(JsonObject jsonObj) { LinkedOmnichannelSubscriptions obj = new LinkedOmnichannelSubscriptions(); - obj.omnichannelSubscriptionId = JsonUtil.getString(json, "omnichannel_subscription_id"); + obj.omnichannelSubscriptionId = JsonUtil.getString(jsonObj, "omnichannel_subscription_id"); return obj; } @@ -588,9 +602,14 @@ public String getOmnichannelOneTimeOrderId() { } public static LinkedOmnichannelOneTimeOrders fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static LinkedOmnichannelOneTimeOrders fromJson(JsonObject jsonObj) { LinkedOmnichannelOneTimeOrders obj = new LinkedOmnichannelOneTimeOrders(); - obj.omnichannelOneTimeOrderId = JsonUtil.getString(json, "omnichannel_one_time_order_id"); + obj.omnichannelOneTimeOrderId = + JsonUtil.getString(jsonObj, "omnichannel_one_time_order_id"); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/omnichannelOneTimeOrder/responses/OmnichannelOneTimeOrderListResponse.java b/src/main/java/com/chargebee/v4/models/omnichannelOneTimeOrder/responses/OmnichannelOneTimeOrderListResponse.java index da448c08..8c2cdcfc 100644 --- a/src/main/java/com/chargebee/v4/models/omnichannelOneTimeOrder/responses/OmnichannelOneTimeOrderListResponse.java +++ b/src/main/java/com/chargebee/v4/models/omnichannelOneTimeOrder/responses/OmnichannelOneTimeOrderListResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.exceptions.ChargebeeException; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; import com.chargebee.v4.services.OmnichannelOneTimeOrderService; import com.chargebee.v4.models.omnichannelOneTimeOrder.params.OmnichannelOneTimeOrderListParams; @@ -46,13 +47,13 @@ private OmnichannelOneTimeOrderListResponse( */ public static OmnichannelOneTimeOrderListResponse fromJson(String json) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(OmnichannelOneTimeOrderListItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "list"), OmnichannelOneTimeOrderListItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new OmnichannelOneTimeOrderListResponse(list, nextOffset, null, null, null); } catch (Exception e) { @@ -71,13 +72,13 @@ public static OmnichannelOneTimeOrderListResponse fromJson( OmnichannelOneTimeOrderListParams originalParams, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(OmnichannelOneTimeOrderListItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "list"), OmnichannelOneTimeOrderListItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new OmnichannelOneTimeOrderListResponse( list, nextOffset, service, originalParams, httpResponse); @@ -186,12 +187,17 @@ public OmnichannelOneTimeOrder getOmnichannelOneTimeOrder() { } public static OmnichannelOneTimeOrderListItem fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static OmnichannelOneTimeOrderListItem fromJson(JsonObject jsonObj) { OmnichannelOneTimeOrderListItem item = new OmnichannelOneTimeOrderListItem(); - String __omnichannelOneTimeOrderJson = JsonUtil.getObject(json, "omnichannel_one_time_order"); - if (__omnichannelOneTimeOrderJson != null) { + JsonObject __omnichannelOneTimeOrderObj = + JsonUtil.getJsonObject(jsonObj, "omnichannel_one_time_order"); + if (__omnichannelOneTimeOrderObj != null) { item.omnichannelOneTimeOrder = - OmnichannelOneTimeOrder.fromJson(__omnichannelOneTimeOrderJson); + OmnichannelOneTimeOrder.fromJson(__omnichannelOneTimeOrderObj); } return item; diff --git a/src/main/java/com/chargebee/v4/models/omnichannelOneTimeOrder/responses/OmnichannelOneTimeOrderRetrieveResponse.java b/src/main/java/com/chargebee/v4/models/omnichannelOneTimeOrder/responses/OmnichannelOneTimeOrderRetrieveResponse.java index d0205db6..843b5f17 100644 --- a/src/main/java/com/chargebee/v4/models/omnichannelOneTimeOrder/responses/OmnichannelOneTimeOrderRetrieveResponse.java +++ b/src/main/java/com/chargebee/v4/models/omnichannelOneTimeOrder/responses/OmnichannelOneTimeOrderRetrieveResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -28,12 +29,14 @@ public static OmnichannelOneTimeOrderRetrieveResponse fromJson(String json) { public static OmnichannelOneTimeOrderRetrieveResponse fromJson( String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __omnichannelOneTimeOrderJson = JsonUtil.getObject(json, "omnichannel_one_time_order"); - if (__omnichannelOneTimeOrderJson != null) { + JsonObject __omnichannelOneTimeOrderObj = + JsonUtil.getJsonObject(jsonObj, "omnichannel_one_time_order"); + if (__omnichannelOneTimeOrderObj != null) { builder.omnichannelOneTimeOrder( - OmnichannelOneTimeOrder.fromJson(__omnichannelOneTimeOrderJson)); + OmnichannelOneTimeOrder.fromJson(__omnichannelOneTimeOrderObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/omnichannelOneTimeOrderItem/OmnichannelOneTimeOrderItem.java b/src/main/java/com/chargebee/v4/models/omnichannelOneTimeOrderItem/OmnichannelOneTimeOrderItem.java index 7fd26291..cba3d698 100644 --- a/src/main/java/com/chargebee/v4/models/omnichannelOneTimeOrderItem/OmnichannelOneTimeOrderItem.java +++ b/src/main/java/com/chargebee/v4/models/omnichannelOneTimeOrderItem/OmnichannelOneTimeOrderItem.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.omnichannelOneTimeOrderItem; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import java.sql.Timestamp; public class OmnichannelOneTimeOrderItem { @@ -88,24 +89,28 @@ public static CancellationReason fromString(String value) { } public static OmnichannelOneTimeOrderItem fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static OmnichannelOneTimeOrderItem fromJson(JsonObject jsonObj) { OmnichannelOneTimeOrderItem obj = new OmnichannelOneTimeOrderItem(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.itemIdAtSource = JsonUtil.getString(json, "item_id_at_source"); + obj.itemIdAtSource = JsonUtil.getString(jsonObj, "item_id_at_source"); - obj.itemTypeAtSource = JsonUtil.getString(json, "item_type_at_source"); + obj.itemTypeAtSource = JsonUtil.getString(jsonObj, "item_type_at_source"); - obj.quantity = JsonUtil.getInteger(json, "quantity"); + obj.quantity = JsonUtil.getInteger(jsonObj, "quantity"); - obj.cancelledAt = JsonUtil.getTimestamp(json, "cancelled_at"); + obj.cancelledAt = JsonUtil.getTimestamp(jsonObj, "cancelled_at"); obj.cancellationReason = - CancellationReason.fromString(JsonUtil.getString(json, "cancellation_reason")); + CancellationReason.fromString(JsonUtil.getString(jsonObj, "cancellation_reason")); - obj.createdAt = JsonUtil.getTimestamp(json, "created_at"); + obj.createdAt = JsonUtil.getTimestamp(jsonObj, "created_at"); - obj.resourceVersion = JsonUtil.getLong(json, "resource_version"); + obj.resourceVersion = JsonUtil.getLong(jsonObj, "resource_version"); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/omnichannelSubscription/OmnichannelSubscription.java b/src/main/java/com/chargebee/v4/models/omnichannelSubscription/OmnichannelSubscription.java index 122123e4..8018c294 100644 --- a/src/main/java/com/chargebee/v4/models/omnichannelSubscription/OmnichannelSubscription.java +++ b/src/main/java/com/chargebee/v4/models/omnichannelSubscription/OmnichannelSubscription.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.omnichannelSubscription; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import java.sql.Timestamp; import java.util.List; @@ -88,33 +89,36 @@ public static Source fromString(String value) { } public static OmnichannelSubscription fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static OmnichannelSubscription fromJson(JsonObject jsonObj) { OmnichannelSubscription obj = new OmnichannelSubscription(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.idAtSource = JsonUtil.getString(json, "id_at_source"); + obj.idAtSource = JsonUtil.getString(jsonObj, "id_at_source"); - obj.appId = JsonUtil.getString(json, "app_id"); + obj.appId = JsonUtil.getString(jsonObj, "app_id"); - obj.source = Source.fromString(JsonUtil.getString(json, "source")); + obj.source = Source.fromString(JsonUtil.getString(jsonObj, "source")); - obj.customerId = JsonUtil.getString(json, "customer_id"); + obj.customerId = JsonUtil.getString(jsonObj, "customer_id"); - obj.createdAt = JsonUtil.getTimestamp(json, "created_at"); + obj.createdAt = JsonUtil.getTimestamp(jsonObj, "created_at"); - obj.resourceVersion = JsonUtil.getLong(json, "resource_version"); + obj.resourceVersion = JsonUtil.getLong(jsonObj, "resource_version"); obj.omnichannelSubscriptionItems = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "omnichannel_subscription_items")) - .stream() - .map(OmnichannelSubscriptionItems::fromJson) - .collect(java.util.stream.Collectors.toList()); - - String __initialPurchaseTransactionJson = - JsonUtil.getObject(json, "initial_purchase_transaction"); - if (__initialPurchaseTransactionJson != null) { + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "omnichannel_subscription_items"), + OmnichannelSubscriptionItems::fromJson); + + JsonObject __initialPurchaseTransactionObj = + JsonUtil.getJsonObject(jsonObj, "initial_purchase_transaction"); + if (__initialPurchaseTransactionObj != null) { obj.initialPurchaseTransaction = - InitialPurchaseTransaction.fromJson(__initialPurchaseTransactionJson); + InitialPurchaseTransaction.fromJson(__initialPurchaseTransactionObj); } return obj; @@ -400,55 +404,58 @@ public static CancellationReason fromString(String value) { } public static OmnichannelSubscriptionItems fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static OmnichannelSubscriptionItems fromJson(JsonObject jsonObj) { OmnichannelSubscriptionItems obj = new OmnichannelSubscriptionItems(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.itemIdAtSource = JsonUtil.getString(json, "item_id_at_source"); + obj.itemIdAtSource = JsonUtil.getString(jsonObj, "item_id_at_source"); - obj.itemParentIdAtSource = JsonUtil.getString(json, "item_parent_id_at_source"); + obj.itemParentIdAtSource = JsonUtil.getString(jsonObj, "item_parent_id_at_source"); - obj.status = Status.fromString(JsonUtil.getString(json, "status")); + obj.status = Status.fromString(JsonUtil.getString(jsonObj, "status")); obj.autoRenewStatus = - AutoRenewStatus.fromString(JsonUtil.getString(json, "auto_renew_status")); + AutoRenewStatus.fromString(JsonUtil.getString(jsonObj, "auto_renew_status")); - obj.currentTermStart = JsonUtil.getTimestamp(json, "current_term_start"); + obj.currentTermStart = JsonUtil.getTimestamp(jsonObj, "current_term_start"); - obj.currentTermEnd = JsonUtil.getTimestamp(json, "current_term_end"); + obj.currentTermEnd = JsonUtil.getTimestamp(jsonObj, "current_term_end"); - obj.expiredAt = JsonUtil.getTimestamp(json, "expired_at"); + obj.expiredAt = JsonUtil.getTimestamp(jsonObj, "expired_at"); obj.expirationReason = - ExpirationReason.fromString(JsonUtil.getString(json, "expiration_reason")); + ExpirationReason.fromString(JsonUtil.getString(jsonObj, "expiration_reason")); - obj.cancelledAt = JsonUtil.getTimestamp(json, "cancelled_at"); + obj.cancelledAt = JsonUtil.getTimestamp(jsonObj, "cancelled_at"); obj.cancellationReason = - CancellationReason.fromString(JsonUtil.getString(json, "cancellation_reason")); + CancellationReason.fromString(JsonUtil.getString(jsonObj, "cancellation_reason")); - obj.gracePeriodExpiresAt = JsonUtil.getTimestamp(json, "grace_period_expires_at"); + obj.gracePeriodExpiresAt = JsonUtil.getTimestamp(jsonObj, "grace_period_expires_at"); - obj.resumesAt = JsonUtil.getTimestamp(json, "resumes_at"); + obj.resumesAt = JsonUtil.getTimestamp(jsonObj, "resumes_at"); - obj.hasScheduledChanges = JsonUtil.getBoolean(json, "has_scheduled_changes"); + obj.hasScheduledChanges = JsonUtil.getBoolean(jsonObj, "has_scheduled_changes"); - obj.resourceVersion = JsonUtil.getLong(json, "resource_version"); + obj.resourceVersion = JsonUtil.getLong(jsonObj, "resource_version"); obj.omnichannelSubscriptionItemOffers = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "omnichannel_subscription_item_offers")) - .stream() - .map(OmnichannelSubscriptionItemOffers::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "omnichannel_subscription_item_offers"), + OmnichannelSubscriptionItemOffers::fromJson); - String __upcomingRenewalJson = JsonUtil.getObject(json, "upcoming_renewal"); - if (__upcomingRenewalJson != null) { - obj.upcomingRenewal = UpcomingRenewal.fromJson(__upcomingRenewalJson); + JsonObject __upcomingRenewalObj = JsonUtil.getJsonObject(jsonObj, "upcoming_renewal"); + if (__upcomingRenewalObj != null) { + obj.upcomingRenewal = UpcomingRenewal.fromJson(__upcomingRenewalObj); } - String __linkedItemJson = JsonUtil.getObject(json, "linked_item"); - if (__linkedItemJson != null) { - obj.linkedItem = LinkedItem.fromJson(__linkedItemJson); + JsonObject __linkedItemObj = JsonUtil.getJsonObject(jsonObj, "linked_item"); + if (__linkedItemObj != null) { + obj.linkedItem = LinkedItem.fromJson(__linkedItemObj); } return obj; @@ -716,37 +723,41 @@ public static DiscountType fromString(String value) { } public static OmnichannelSubscriptionItemOffers fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static OmnichannelSubscriptionItemOffers fromJson(JsonObject jsonObj) { OmnichannelSubscriptionItemOffers obj = new OmnichannelSubscriptionItemOffers(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.offerIdAtSource = JsonUtil.getString(json, "offer_id_at_source"); + obj.offerIdAtSource = JsonUtil.getString(jsonObj, "offer_id_at_source"); - obj.category = Category.fromString(JsonUtil.getString(json, "category")); + obj.category = Category.fromString(JsonUtil.getString(jsonObj, "category")); - obj.categoryAtSource = JsonUtil.getString(json, "category_at_source"); + obj.categoryAtSource = JsonUtil.getString(jsonObj, "category_at_source"); - obj.type = Type.fromString(JsonUtil.getString(json, "type")); + obj.type = Type.fromString(JsonUtil.getString(jsonObj, "type")); - obj.typeAtSource = JsonUtil.getString(json, "type_at_source"); + obj.typeAtSource = JsonUtil.getString(jsonObj, "type_at_source"); - obj.discountType = DiscountType.fromString(JsonUtil.getString(json, "discount_type")); + obj.discountType = DiscountType.fromString(JsonUtil.getString(jsonObj, "discount_type")); - obj.duration = JsonUtil.getString(json, "duration"); + obj.duration = JsonUtil.getString(jsonObj, "duration"); - obj.percentage = JsonUtil.getDouble(json, "percentage"); + obj.percentage = JsonUtil.getDouble(jsonObj, "percentage"); - obj.priceCurrency = JsonUtil.getString(json, "price_currency"); + obj.priceCurrency = JsonUtil.getString(jsonObj, "price_currency"); - obj.priceUnits = JsonUtil.getLong(json, "price_units"); + obj.priceUnits = JsonUtil.getLong(jsonObj, "price_units"); - obj.priceNanos = JsonUtil.getLong(json, "price_nanos"); + obj.priceNanos = JsonUtil.getLong(jsonObj, "price_nanos"); - obj.offerTermStart = JsonUtil.getTimestamp(json, "offer_term_start"); + obj.offerTermStart = JsonUtil.getTimestamp(jsonObj, "offer_term_start"); - obj.offerTermEnd = JsonUtil.getTimestamp(json, "offer_term_end"); + obj.offerTermEnd = JsonUtil.getTimestamp(jsonObj, "offer_term_end"); - obj.resourceVersion = JsonUtil.getLong(json, "resource_version"); + obj.resourceVersion = JsonUtil.getLong(jsonObj, "resource_version"); return obj; } @@ -851,13 +862,17 @@ public Long getPriceNanos() { } public static UpcomingRenewal fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static UpcomingRenewal fromJson(JsonObject jsonObj) { UpcomingRenewal obj = new UpcomingRenewal(); - obj.priceCurrency = JsonUtil.getString(json, "price_currency"); + obj.priceCurrency = JsonUtil.getString(jsonObj, "price_currency"); - obj.priceUnits = JsonUtil.getLong(json, "price_units"); + obj.priceUnits = JsonUtil.getLong(jsonObj, "price_units"); - obj.priceNanos = JsonUtil.getLong(json, "price_nanos"); + obj.priceNanos = JsonUtil.getLong(jsonObj, "price_nanos"); return obj; } @@ -906,11 +921,15 @@ public Timestamp getLinkedAt() { } public static LinkedItem fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static LinkedItem fromJson(JsonObject jsonObj) { LinkedItem obj = new LinkedItem(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.linkedAt = JsonUtil.getTimestamp(json, "linked_at"); + obj.linkedAt = JsonUtil.getTimestamp(jsonObj, "linked_at"); return obj; } @@ -1030,39 +1049,41 @@ public static Type fromString(String value) { } public static InitialPurchaseTransaction fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static InitialPurchaseTransaction fromJson(JsonObject jsonObj) { InitialPurchaseTransaction obj = new InitialPurchaseTransaction(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.idAtSource = JsonUtil.getString(json, "id_at_source"); + obj.idAtSource = JsonUtil.getString(jsonObj, "id_at_source"); - obj.appId = JsonUtil.getString(json, "app_id"); + obj.appId = JsonUtil.getString(jsonObj, "app_id"); - obj.priceCurrency = JsonUtil.getString(json, "price_currency"); + obj.priceCurrency = JsonUtil.getString(jsonObj, "price_currency"); - obj.priceUnits = JsonUtil.getLong(json, "price_units"); + obj.priceUnits = JsonUtil.getLong(jsonObj, "price_units"); - obj.priceNanos = JsonUtil.getLong(json, "price_nanos"); + obj.priceNanos = JsonUtil.getLong(jsonObj, "price_nanos"); - obj.type = Type.fromString(JsonUtil.getString(json, "type")); + obj.type = Type.fromString(JsonUtil.getString(jsonObj, "type")); - obj.transactedAt = JsonUtil.getTimestamp(json, "transacted_at"); + obj.transactedAt = JsonUtil.getTimestamp(jsonObj, "transacted_at"); - obj.createdAt = JsonUtil.getTimestamp(json, "created_at"); + obj.createdAt = JsonUtil.getTimestamp(jsonObj, "created_at"); - obj.resourceVersion = JsonUtil.getLong(json, "resource_version"); + obj.resourceVersion = JsonUtil.getLong(jsonObj, "resource_version"); obj.linkedOmnichannelSubscriptions = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "linked_omnichannel_subscriptions")) - .stream() - .map(LinkedOmnichannelSubscriptions::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "linked_omnichannel_subscriptions"), + LinkedOmnichannelSubscriptions::fromJson); obj.linkedOmnichannelOneTimeOrders = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "linked_omnichannel_one_time_orders")) - .stream() - .map(LinkedOmnichannelOneTimeOrders::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "linked_omnichannel_one_time_orders"), + LinkedOmnichannelOneTimeOrders::fromJson); return obj; } @@ -1146,9 +1167,13 @@ public String getOmnichannelSubscriptionId() { } public static LinkedOmnichannelSubscriptions fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static LinkedOmnichannelSubscriptions fromJson(JsonObject jsonObj) { LinkedOmnichannelSubscriptions obj = new LinkedOmnichannelSubscriptions(); - obj.omnichannelSubscriptionId = JsonUtil.getString(json, "omnichannel_subscription_id"); + obj.omnichannelSubscriptionId = JsonUtil.getString(jsonObj, "omnichannel_subscription_id"); return obj; } @@ -1186,9 +1211,14 @@ public String getOmnichannelOneTimeOrderId() { } public static LinkedOmnichannelOneTimeOrders fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static LinkedOmnichannelOneTimeOrders fromJson(JsonObject jsonObj) { LinkedOmnichannelOneTimeOrders obj = new LinkedOmnichannelOneTimeOrders(); - obj.omnichannelOneTimeOrderId = JsonUtil.getString(json, "omnichannel_one_time_order_id"); + obj.omnichannelOneTimeOrderId = + JsonUtil.getString(jsonObj, "omnichannel_one_time_order_id"); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/omnichannelSubscription/responses/OmnichannelSubscriptionListResponse.java b/src/main/java/com/chargebee/v4/models/omnichannelSubscription/responses/OmnichannelSubscriptionListResponse.java index 3b4f0260..43964c30 100644 --- a/src/main/java/com/chargebee/v4/models/omnichannelSubscription/responses/OmnichannelSubscriptionListResponse.java +++ b/src/main/java/com/chargebee/v4/models/omnichannelSubscription/responses/OmnichannelSubscriptionListResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.exceptions.ChargebeeException; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; import com.chargebee.v4.services.OmnichannelSubscriptionService; import com.chargebee.v4.models.omnichannelSubscription.params.OmnichannelSubscriptionListParams; @@ -46,13 +47,13 @@ private OmnichannelSubscriptionListResponse( */ public static OmnichannelSubscriptionListResponse fromJson(String json) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(OmnichannelSubscriptionListItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "list"), OmnichannelSubscriptionListItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new OmnichannelSubscriptionListResponse(list, nextOffset, null, null, null); } catch (Exception e) { @@ -71,13 +72,13 @@ public static OmnichannelSubscriptionListResponse fromJson( OmnichannelSubscriptionListParams originalParams, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(OmnichannelSubscriptionListItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "list"), OmnichannelSubscriptionListItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new OmnichannelSubscriptionListResponse( list, nextOffset, service, originalParams, httpResponse); @@ -186,12 +187,17 @@ public OmnichannelSubscription getOmnichannelSubscription() { } public static OmnichannelSubscriptionListItem fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static OmnichannelSubscriptionListItem fromJson(JsonObject jsonObj) { OmnichannelSubscriptionListItem item = new OmnichannelSubscriptionListItem(); - String __omnichannelSubscriptionJson = JsonUtil.getObject(json, "omnichannel_subscription"); - if (__omnichannelSubscriptionJson != null) { + JsonObject __omnichannelSubscriptionObj = + JsonUtil.getJsonObject(jsonObj, "omnichannel_subscription"); + if (__omnichannelSubscriptionObj != null) { item.omnichannelSubscription = - OmnichannelSubscription.fromJson(__omnichannelSubscriptionJson); + OmnichannelSubscription.fromJson(__omnichannelSubscriptionObj); } return item; diff --git a/src/main/java/com/chargebee/v4/models/omnichannelSubscription/responses/OmnichannelSubscriptionMoveResponse.java b/src/main/java/com/chargebee/v4/models/omnichannelSubscription/responses/OmnichannelSubscriptionMoveResponse.java index f757b454..f3331540 100644 --- a/src/main/java/com/chargebee/v4/models/omnichannelSubscription/responses/OmnichannelSubscriptionMoveResponse.java +++ b/src/main/java/com/chargebee/v4/models/omnichannelSubscription/responses/OmnichannelSubscriptionMoveResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,12 +28,14 @@ public static OmnichannelSubscriptionMoveResponse fromJson(String json) { /** Parse JSON response into OmnichannelSubscriptionMoveResponse object with HTTP response. */ public static OmnichannelSubscriptionMoveResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __omnichannelSubscriptionJson = JsonUtil.getObject(json, "omnichannel_subscription"); - if (__omnichannelSubscriptionJson != null) { + JsonObject __omnichannelSubscriptionObj = + JsonUtil.getJsonObject(jsonObj, "omnichannel_subscription"); + if (__omnichannelSubscriptionObj != null) { builder.omnichannelSubscription( - OmnichannelSubscription.fromJson(__omnichannelSubscriptionJson)); + OmnichannelSubscription.fromJson(__omnichannelSubscriptionObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/omnichannelSubscription/responses/OmnichannelSubscriptionRetrieveResponse.java b/src/main/java/com/chargebee/v4/models/omnichannelSubscription/responses/OmnichannelSubscriptionRetrieveResponse.java index f308a300..06f75926 100644 --- a/src/main/java/com/chargebee/v4/models/omnichannelSubscription/responses/OmnichannelSubscriptionRetrieveResponse.java +++ b/src/main/java/com/chargebee/v4/models/omnichannelSubscription/responses/OmnichannelSubscriptionRetrieveResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -28,12 +29,14 @@ public static OmnichannelSubscriptionRetrieveResponse fromJson(String json) { public static OmnichannelSubscriptionRetrieveResponse fromJson( String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __omnichannelSubscriptionJson = JsonUtil.getObject(json, "omnichannel_subscription"); - if (__omnichannelSubscriptionJson != null) { + JsonObject __omnichannelSubscriptionObj = + JsonUtil.getJsonObject(jsonObj, "omnichannel_subscription"); + if (__omnichannelSubscriptionObj != null) { builder.omnichannelSubscription( - OmnichannelSubscription.fromJson(__omnichannelSubscriptionJson)); + OmnichannelSubscription.fromJson(__omnichannelSubscriptionObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/omnichannelSubscription/responses/OmnichannelTransactionsForOmnichannelSubscriptionResponse.java b/src/main/java/com/chargebee/v4/models/omnichannelSubscription/responses/OmnichannelTransactionsForOmnichannelSubscriptionResponse.java index 43cea6e6..c1f259ac 100644 --- a/src/main/java/com/chargebee/v4/models/omnichannelSubscription/responses/OmnichannelTransactionsForOmnichannelSubscriptionResponse.java +++ b/src/main/java/com/chargebee/v4/models/omnichannelSubscription/responses/OmnichannelTransactionsForOmnichannelSubscriptionResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.exceptions.ChargebeeException; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; import com.chargebee.v4.services.OmnichannelSubscriptionService; import com.chargebee.v4.models.omnichannelSubscription.params.OmnichannelTransactionsForOmnichannelSubscriptionParams; @@ -52,15 +53,15 @@ private OmnichannelTransactionsForOmnichannelSubscriptionResponse( */ public static OmnichannelTransactionsForOmnichannelSubscriptionResponse fromJson(String json) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map( - OmnichannelSubscriptionOmnichannelTransactionsForOmnichannelSubscriptionItem - ::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "list"), + OmnichannelSubscriptionOmnichannelTransactionsForOmnichannelSubscriptionItem + ::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new OmnichannelTransactionsForOmnichannelSubscriptionResponse( list, nextOffset, null, null, null, null); @@ -81,15 +82,15 @@ public static OmnichannelTransactionsForOmnichannelSubscriptionResponse fromJson String omnichannelSubscriptionId, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map( - OmnichannelSubscriptionOmnichannelTransactionsForOmnichannelSubscriptionItem - ::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "list"), + OmnichannelSubscriptionOmnichannelTransactionsForOmnichannelSubscriptionItem + ::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new OmnichannelTransactionsForOmnichannelSubscriptionResponse( list, nextOffset, omnichannelSubscriptionId, service, originalParams, httpResponse); @@ -203,12 +204,18 @@ public OmnichannelTransaction getOmnichannelTransaction() { public static OmnichannelSubscriptionOmnichannelTransactionsForOmnichannelSubscriptionItem fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static OmnichannelSubscriptionOmnichannelTransactionsForOmnichannelSubscriptionItem + fromJson(JsonObject jsonObj) { OmnichannelSubscriptionOmnichannelTransactionsForOmnichannelSubscriptionItem item = new OmnichannelSubscriptionOmnichannelTransactionsForOmnichannelSubscriptionItem(); - String __omnichannelTransactionJson = JsonUtil.getObject(json, "omnichannel_transaction"); - if (__omnichannelTransactionJson != null) { - item.omnichannelTransaction = OmnichannelTransaction.fromJson(__omnichannelTransactionJson); + JsonObject __omnichannelTransactionObj = + JsonUtil.getJsonObject(jsonObj, "omnichannel_transaction"); + if (__omnichannelTransactionObj != null) { + item.omnichannelTransaction = OmnichannelTransaction.fromJson(__omnichannelTransactionObj); } return item; diff --git a/src/main/java/com/chargebee/v4/models/omnichannelSubscriptionItem/OmnichannelSubscriptionItem.java b/src/main/java/com/chargebee/v4/models/omnichannelSubscriptionItem/OmnichannelSubscriptionItem.java index 08843cf1..b0febf97 100644 --- a/src/main/java/com/chargebee/v4/models/omnichannelSubscriptionItem/OmnichannelSubscriptionItem.java +++ b/src/main/java/com/chargebee/v4/models/omnichannelSubscriptionItem/OmnichannelSubscriptionItem.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.omnichannelSubscriptionItem; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import java.sql.Timestamp; import java.util.List; @@ -233,54 +234,58 @@ public static CancellationReason fromString(String value) { } public static OmnichannelSubscriptionItem fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static OmnichannelSubscriptionItem fromJson(JsonObject jsonObj) { OmnichannelSubscriptionItem obj = new OmnichannelSubscriptionItem(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.itemIdAtSource = JsonUtil.getString(json, "item_id_at_source"); + obj.itemIdAtSource = JsonUtil.getString(jsonObj, "item_id_at_source"); - obj.itemParentIdAtSource = JsonUtil.getString(json, "item_parent_id_at_source"); + obj.itemParentIdAtSource = JsonUtil.getString(jsonObj, "item_parent_id_at_source"); - obj.status = Status.fromString(JsonUtil.getString(json, "status")); + obj.status = Status.fromString(JsonUtil.getString(jsonObj, "status")); - obj.autoRenewStatus = AutoRenewStatus.fromString(JsonUtil.getString(json, "auto_renew_status")); + obj.autoRenewStatus = + AutoRenewStatus.fromString(JsonUtil.getString(jsonObj, "auto_renew_status")); - obj.currentTermStart = JsonUtil.getTimestamp(json, "current_term_start"); + obj.currentTermStart = JsonUtil.getTimestamp(jsonObj, "current_term_start"); - obj.currentTermEnd = JsonUtil.getTimestamp(json, "current_term_end"); + obj.currentTermEnd = JsonUtil.getTimestamp(jsonObj, "current_term_end"); - obj.expiredAt = JsonUtil.getTimestamp(json, "expired_at"); + obj.expiredAt = JsonUtil.getTimestamp(jsonObj, "expired_at"); obj.expirationReason = - ExpirationReason.fromString(JsonUtil.getString(json, "expiration_reason")); + ExpirationReason.fromString(JsonUtil.getString(jsonObj, "expiration_reason")); - obj.cancelledAt = JsonUtil.getTimestamp(json, "cancelled_at"); + obj.cancelledAt = JsonUtil.getTimestamp(jsonObj, "cancelled_at"); obj.cancellationReason = - CancellationReason.fromString(JsonUtil.getString(json, "cancellation_reason")); + CancellationReason.fromString(JsonUtil.getString(jsonObj, "cancellation_reason")); - obj.gracePeriodExpiresAt = JsonUtil.getTimestamp(json, "grace_period_expires_at"); + obj.gracePeriodExpiresAt = JsonUtil.getTimestamp(jsonObj, "grace_period_expires_at"); - obj.resumesAt = JsonUtil.getTimestamp(json, "resumes_at"); + obj.resumesAt = JsonUtil.getTimestamp(jsonObj, "resumes_at"); - obj.hasScheduledChanges = JsonUtil.getBoolean(json, "has_scheduled_changes"); + obj.hasScheduledChanges = JsonUtil.getBoolean(jsonObj, "has_scheduled_changes"); - obj.resourceVersion = JsonUtil.getLong(json, "resource_version"); + obj.resourceVersion = JsonUtil.getLong(jsonObj, "resource_version"); obj.omnichannelSubscriptionItemOffers = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "omnichannel_subscription_item_offers")) - .stream() - .map(OmnichannelSubscriptionItemOffers::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "omnichannel_subscription_item_offers"), + OmnichannelSubscriptionItemOffers::fromJson); - String __upcomingRenewalJson = JsonUtil.getObject(json, "upcoming_renewal"); - if (__upcomingRenewalJson != null) { - obj.upcomingRenewal = UpcomingRenewal.fromJson(__upcomingRenewalJson); + JsonObject __upcomingRenewalObj = JsonUtil.getJsonObject(jsonObj, "upcoming_renewal"); + if (__upcomingRenewalObj != null) { + obj.upcomingRenewal = UpcomingRenewal.fromJson(__upcomingRenewalObj); } - String __linkedItemJson = JsonUtil.getObject(json, "linked_item"); - if (__linkedItemJson != null) { - obj.linkedItem = LinkedItem.fromJson(__linkedItemJson); + JsonObject __linkedItemObj = JsonUtil.getJsonObject(jsonObj, "linked_item"); + if (__linkedItemObj != null) { + obj.linkedItem = LinkedItem.fromJson(__linkedItemObj); } return obj; @@ -548,37 +553,41 @@ public static DiscountType fromString(String value) { } public static OmnichannelSubscriptionItemOffers fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static OmnichannelSubscriptionItemOffers fromJson(JsonObject jsonObj) { OmnichannelSubscriptionItemOffers obj = new OmnichannelSubscriptionItemOffers(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.offerIdAtSource = JsonUtil.getString(json, "offer_id_at_source"); + obj.offerIdAtSource = JsonUtil.getString(jsonObj, "offer_id_at_source"); - obj.category = Category.fromString(JsonUtil.getString(json, "category")); + obj.category = Category.fromString(JsonUtil.getString(jsonObj, "category")); - obj.categoryAtSource = JsonUtil.getString(json, "category_at_source"); + obj.categoryAtSource = JsonUtil.getString(jsonObj, "category_at_source"); - obj.type = Type.fromString(JsonUtil.getString(json, "type")); + obj.type = Type.fromString(JsonUtil.getString(jsonObj, "type")); - obj.typeAtSource = JsonUtil.getString(json, "type_at_source"); + obj.typeAtSource = JsonUtil.getString(jsonObj, "type_at_source"); - obj.discountType = DiscountType.fromString(JsonUtil.getString(json, "discount_type")); + obj.discountType = DiscountType.fromString(JsonUtil.getString(jsonObj, "discount_type")); - obj.duration = JsonUtil.getString(json, "duration"); + obj.duration = JsonUtil.getString(jsonObj, "duration"); - obj.percentage = JsonUtil.getDouble(json, "percentage"); + obj.percentage = JsonUtil.getDouble(jsonObj, "percentage"); - obj.priceCurrency = JsonUtil.getString(json, "price_currency"); + obj.priceCurrency = JsonUtil.getString(jsonObj, "price_currency"); - obj.priceUnits = JsonUtil.getLong(json, "price_units"); + obj.priceUnits = JsonUtil.getLong(jsonObj, "price_units"); - obj.priceNanos = JsonUtil.getLong(json, "price_nanos"); + obj.priceNanos = JsonUtil.getLong(jsonObj, "price_nanos"); - obj.offerTermStart = JsonUtil.getTimestamp(json, "offer_term_start"); + obj.offerTermStart = JsonUtil.getTimestamp(jsonObj, "offer_term_start"); - obj.offerTermEnd = JsonUtil.getTimestamp(json, "offer_term_end"); + obj.offerTermEnd = JsonUtil.getTimestamp(jsonObj, "offer_term_end"); - obj.resourceVersion = JsonUtil.getLong(json, "resource_version"); + obj.resourceVersion = JsonUtil.getLong(jsonObj, "resource_version"); return obj; } @@ -683,13 +692,17 @@ public Long getPriceNanos() { } public static UpcomingRenewal fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static UpcomingRenewal fromJson(JsonObject jsonObj) { UpcomingRenewal obj = new UpcomingRenewal(); - obj.priceCurrency = JsonUtil.getString(json, "price_currency"); + obj.priceCurrency = JsonUtil.getString(jsonObj, "price_currency"); - obj.priceUnits = JsonUtil.getLong(json, "price_units"); + obj.priceUnits = JsonUtil.getLong(jsonObj, "price_units"); - obj.priceNanos = JsonUtil.getLong(json, "price_nanos"); + obj.priceNanos = JsonUtil.getLong(jsonObj, "price_nanos"); return obj; } @@ -738,11 +751,15 @@ public Timestamp getLinkedAt() { } public static LinkedItem fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static LinkedItem fromJson(JsonObject jsonObj) { LinkedItem obj = new LinkedItem(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.linkedAt = JsonUtil.getTimestamp(json, "linked_at"); + obj.linkedAt = JsonUtil.getTimestamp(jsonObj, "linked_at"); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/omnichannelSubscriptionItem/responses/OmnichannelSubscriptionItemListOmniSubscriptionItemScheduleChangesResponse.java b/src/main/java/com/chargebee/v4/models/omnichannelSubscriptionItem/responses/OmnichannelSubscriptionItemListOmniSubscriptionItemScheduleChangesResponse.java index bb47c268..6eff36dd 100644 --- a/src/main/java/com/chargebee/v4/models/omnichannelSubscriptionItem/responses/OmnichannelSubscriptionItemListOmniSubscriptionItemScheduleChangesResponse.java +++ b/src/main/java/com/chargebee/v4/models/omnichannelSubscriptionItem/responses/OmnichannelSubscriptionItemListOmniSubscriptionItemScheduleChangesResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.exceptions.ChargebeeException; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; import com.chargebee.v4.services.OmnichannelSubscriptionItemService; import com.chargebee.v4.models.omnichannelSubscriptionItem.params.OmnichannelSubscriptionItemListOmniSubscriptionItemScheduleChangesParams; @@ -54,13 +55,14 @@ private OmnichannelSubscriptionItemListOmniSubscriptionItemScheduleChangesRespon public static OmnichannelSubscriptionItemListOmniSubscriptionItemScheduleChangesResponse fromJson( String json) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(OmnichannelSubscriptionItemListOmniSubscriptionItemScheduleChangesItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "list"), + OmnichannelSubscriptionItemListOmniSubscriptionItemScheduleChangesItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new OmnichannelSubscriptionItemListOmniSubscriptionItemScheduleChangesResponse( list, nextOffset, null, null, null, null); @@ -83,13 +85,14 @@ public static OmnichannelSubscriptionItemListOmniSubscriptionItemScheduleChanges String omnichannelSubscriptionItemId, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(OmnichannelSubscriptionItemListOmniSubscriptionItemScheduleChangesItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "list"), + OmnichannelSubscriptionItemListOmniSubscriptionItemScheduleChangesItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new OmnichannelSubscriptionItemListOmniSubscriptionItemScheduleChangesResponse( list, nextOffset, omnichannelSubscriptionItemId, service, originalParams, httpResponse); @@ -205,15 +208,20 @@ public static class OmnichannelSubscriptionItemListOmniSubscriptionItemScheduleC public static OmnichannelSubscriptionItemListOmniSubscriptionItemScheduleChangesItem fromJson( String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static OmnichannelSubscriptionItemListOmniSubscriptionItemScheduleChangesItem fromJson( + JsonObject jsonObj) { OmnichannelSubscriptionItemListOmniSubscriptionItemScheduleChangesItem item = new OmnichannelSubscriptionItemListOmniSubscriptionItemScheduleChangesItem(); - String __omnichannelSubscriptionItemScheduledChangeJson = - JsonUtil.getObject(json, "omnichannel_subscription_item_scheduled_change"); - if (__omnichannelSubscriptionItemScheduledChangeJson != null) { + JsonObject __omnichannelSubscriptionItemScheduledChangeObj = + JsonUtil.getJsonObject(jsonObj, "omnichannel_subscription_item_scheduled_change"); + if (__omnichannelSubscriptionItemScheduledChangeObj != null) { item.omnichannelSubscriptionItemScheduledChange = OmnichannelSubscriptionItemScheduledChange.fromJson( - __omnichannelSubscriptionItemScheduledChangeJson); + __omnichannelSubscriptionItemScheduledChangeObj); } return item; diff --git a/src/main/java/com/chargebee/v4/models/omnichannelSubscriptionItemOffer/OmnichannelSubscriptionItemOffer.java b/src/main/java/com/chargebee/v4/models/omnichannelSubscriptionItemOffer/OmnichannelSubscriptionItemOffer.java index ba0faed1..06e1d172 100644 --- a/src/main/java/com/chargebee/v4/models/omnichannelSubscriptionItemOffer/OmnichannelSubscriptionItemOffer.java +++ b/src/main/java/com/chargebee/v4/models/omnichannelSubscriptionItemOffer/OmnichannelSubscriptionItemOffer.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.omnichannelSubscriptionItemOffer; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import java.sql.Timestamp; public class OmnichannelSubscriptionItemOffer { @@ -179,37 +180,41 @@ public static DiscountType fromString(String value) { } public static OmnichannelSubscriptionItemOffer fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static OmnichannelSubscriptionItemOffer fromJson(JsonObject jsonObj) { OmnichannelSubscriptionItemOffer obj = new OmnichannelSubscriptionItemOffer(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.offerIdAtSource = JsonUtil.getString(json, "offer_id_at_source"); + obj.offerIdAtSource = JsonUtil.getString(jsonObj, "offer_id_at_source"); - obj.category = Category.fromString(JsonUtil.getString(json, "category")); + obj.category = Category.fromString(JsonUtil.getString(jsonObj, "category")); - obj.categoryAtSource = JsonUtil.getString(json, "category_at_source"); + obj.categoryAtSource = JsonUtil.getString(jsonObj, "category_at_source"); - obj.type = Type.fromString(JsonUtil.getString(json, "type")); + obj.type = Type.fromString(JsonUtil.getString(jsonObj, "type")); - obj.typeAtSource = JsonUtil.getString(json, "type_at_source"); + obj.typeAtSource = JsonUtil.getString(jsonObj, "type_at_source"); - obj.discountType = DiscountType.fromString(JsonUtil.getString(json, "discount_type")); + obj.discountType = DiscountType.fromString(JsonUtil.getString(jsonObj, "discount_type")); - obj.duration = JsonUtil.getString(json, "duration"); + obj.duration = JsonUtil.getString(jsonObj, "duration"); - obj.percentage = JsonUtil.getDouble(json, "percentage"); + obj.percentage = JsonUtil.getDouble(jsonObj, "percentage"); - obj.priceCurrency = JsonUtil.getString(json, "price_currency"); + obj.priceCurrency = JsonUtil.getString(jsonObj, "price_currency"); - obj.priceUnits = JsonUtil.getLong(json, "price_units"); + obj.priceUnits = JsonUtil.getLong(jsonObj, "price_units"); - obj.priceNanos = JsonUtil.getLong(json, "price_nanos"); + obj.priceNanos = JsonUtil.getLong(jsonObj, "price_nanos"); - obj.offerTermStart = JsonUtil.getTimestamp(json, "offer_term_start"); + obj.offerTermStart = JsonUtil.getTimestamp(jsonObj, "offer_term_start"); - obj.offerTermEnd = JsonUtil.getTimestamp(json, "offer_term_end"); + obj.offerTermEnd = JsonUtil.getTimestamp(jsonObj, "offer_term_end"); - obj.resourceVersion = JsonUtil.getLong(json, "resource_version"); + obj.resourceVersion = JsonUtil.getLong(jsonObj, "resource_version"); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/omnichannelSubscriptionItemScheduledChange/OmnichannelSubscriptionItemScheduledChange.java b/src/main/java/com/chargebee/v4/models/omnichannelSubscriptionItemScheduledChange/OmnichannelSubscriptionItemScheduledChange.java index 434fd647..eeac701f 100644 --- a/src/main/java/com/chargebee/v4/models/omnichannelSubscriptionItemScheduledChange/OmnichannelSubscriptionItemScheduledChange.java +++ b/src/main/java/com/chargebee/v4/models/omnichannelSubscriptionItemScheduledChange/OmnichannelSubscriptionItemScheduledChange.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.omnichannelSubscriptionItemScheduledChange; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import java.sql.Timestamp; public class OmnichannelSubscriptionItemScheduledChange { @@ -87,32 +88,36 @@ public static ChangeType fromString(String value) { } public static OmnichannelSubscriptionItemScheduledChange fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static OmnichannelSubscriptionItemScheduledChange fromJson(JsonObject jsonObj) { OmnichannelSubscriptionItemScheduledChange obj = new OmnichannelSubscriptionItemScheduledChange(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); obj.omnichannelSubscriptionItemId = - JsonUtil.getString(json, "omnichannel_subscription_item_id"); + JsonUtil.getString(jsonObj, "omnichannel_subscription_item_id"); - obj.scheduledAt = JsonUtil.getTimestamp(json, "scheduled_at"); + obj.scheduledAt = JsonUtil.getTimestamp(jsonObj, "scheduled_at"); - obj.changeType = ChangeType.fromString(JsonUtil.getString(json, "change_type")); + obj.changeType = ChangeType.fromString(JsonUtil.getString(jsonObj, "change_type")); - obj.createdAt = JsonUtil.getTimestamp(json, "created_at"); + obj.createdAt = JsonUtil.getTimestamp(jsonObj, "created_at"); - obj.modifiedAt = JsonUtil.getTimestamp(json, "modified_at"); + obj.modifiedAt = JsonUtil.getTimestamp(jsonObj, "modified_at"); - obj.resourceVersion = JsonUtil.getLong(json, "resource_version"); + obj.resourceVersion = JsonUtil.getLong(jsonObj, "resource_version"); - String __currentStateJson = JsonUtil.getObject(json, "current_state"); - if (__currentStateJson != null) { - obj.currentState = CurrentState.fromJson(__currentStateJson); + JsonObject __currentStateObj = JsonUtil.getJsonObject(jsonObj, "current_state"); + if (__currentStateObj != null) { + obj.currentState = CurrentState.fromJson(__currentStateObj); } - String __scheduledStateJson = JsonUtil.getObject(json, "scheduled_state"); - if (__scheduledStateJson != null) { - obj.scheduledState = ScheduledState.fromJson(__scheduledStateJson); + JsonObject __scheduledStateObj = JsonUtil.getJsonObject(jsonObj, "scheduled_state"); + if (__scheduledStateObj != null) { + obj.scheduledState = ScheduledState.fromJson(__scheduledStateObj); } return obj; @@ -185,9 +190,13 @@ public String getItemIdAtSource() { } public static CurrentState fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static CurrentState fromJson(JsonObject jsonObj) { CurrentState obj = new CurrentState(); - obj.itemIdAtSource = JsonUtil.getString(json, "item_id_at_source"); + obj.itemIdAtSource = JsonUtil.getString(jsonObj, "item_id_at_source"); return obj; } @@ -222,9 +231,13 @@ public String getItemIdAtSource() { } public static ScheduledState fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static ScheduledState fromJson(JsonObject jsonObj) { ScheduledState obj = new ScheduledState(); - obj.itemIdAtSource = JsonUtil.getString(json, "item_id_at_source"); + obj.itemIdAtSource = JsonUtil.getString(jsonObj, "item_id_at_source"); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/omnichannelTransaction/OmnichannelTransaction.java b/src/main/java/com/chargebee/v4/models/omnichannelTransaction/OmnichannelTransaction.java index 3305385b..65d7de8a 100644 --- a/src/main/java/com/chargebee/v4/models/omnichannelTransaction/OmnichannelTransaction.java +++ b/src/main/java/com/chargebee/v4/models/omnichannelTransaction/OmnichannelTransaction.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.omnichannelTransaction; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import java.sql.Timestamp; import java.util.List; @@ -103,39 +104,41 @@ public static Type fromString(String value) { } public static OmnichannelTransaction fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static OmnichannelTransaction fromJson(JsonObject jsonObj) { OmnichannelTransaction obj = new OmnichannelTransaction(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.idAtSource = JsonUtil.getString(json, "id_at_source"); + obj.idAtSource = JsonUtil.getString(jsonObj, "id_at_source"); - obj.appId = JsonUtil.getString(json, "app_id"); + obj.appId = JsonUtil.getString(jsonObj, "app_id"); - obj.priceCurrency = JsonUtil.getString(json, "price_currency"); + obj.priceCurrency = JsonUtil.getString(jsonObj, "price_currency"); - obj.priceUnits = JsonUtil.getLong(json, "price_units"); + obj.priceUnits = JsonUtil.getLong(jsonObj, "price_units"); - obj.priceNanos = JsonUtil.getLong(json, "price_nanos"); + obj.priceNanos = JsonUtil.getLong(jsonObj, "price_nanos"); - obj.type = Type.fromString(JsonUtil.getString(json, "type")); + obj.type = Type.fromString(JsonUtil.getString(jsonObj, "type")); - obj.transactedAt = JsonUtil.getTimestamp(json, "transacted_at"); + obj.transactedAt = JsonUtil.getTimestamp(jsonObj, "transacted_at"); - obj.createdAt = JsonUtil.getTimestamp(json, "created_at"); + obj.createdAt = JsonUtil.getTimestamp(jsonObj, "created_at"); - obj.resourceVersion = JsonUtil.getLong(json, "resource_version"); + obj.resourceVersion = JsonUtil.getLong(jsonObj, "resource_version"); obj.linkedOmnichannelSubscriptions = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "linked_omnichannel_subscriptions")) - .stream() - .map(LinkedOmnichannelSubscriptions::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "linked_omnichannel_subscriptions"), + LinkedOmnichannelSubscriptions::fromJson); obj.linkedOmnichannelOneTimeOrders = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "linked_omnichannel_one_time_orders")) - .stream() - .map(LinkedOmnichannelOneTimeOrders::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "linked_omnichannel_one_time_orders"), + LinkedOmnichannelOneTimeOrders::fromJson); return obj; } @@ -219,9 +222,13 @@ public String getOmnichannelSubscriptionId() { } public static LinkedOmnichannelSubscriptions fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static LinkedOmnichannelSubscriptions fromJson(JsonObject jsonObj) { LinkedOmnichannelSubscriptions obj = new LinkedOmnichannelSubscriptions(); - obj.omnichannelSubscriptionId = JsonUtil.getString(json, "omnichannel_subscription_id"); + obj.omnichannelSubscriptionId = JsonUtil.getString(jsonObj, "omnichannel_subscription_id"); return obj; } @@ -259,9 +266,13 @@ public String getOmnichannelOneTimeOrderId() { } public static LinkedOmnichannelOneTimeOrders fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static LinkedOmnichannelOneTimeOrders fromJson(JsonObject jsonObj) { LinkedOmnichannelOneTimeOrders obj = new LinkedOmnichannelOneTimeOrders(); - obj.omnichannelOneTimeOrderId = JsonUtil.getString(json, "omnichannel_one_time_order_id"); + obj.omnichannelOneTimeOrderId = JsonUtil.getString(jsonObj, "omnichannel_one_time_order_id"); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/order/Order.java b/src/main/java/com/chargebee/v4/models/order/Order.java index df043329..418b8bf2 100644 --- a/src/main/java/com/chargebee/v4/models/order/Order.java +++ b/src/main/java/com/chargebee/v4/models/order/Order.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.order; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import java.math.BigDecimal; import java.sql.Timestamp; import java.util.List; @@ -508,141 +509,139 @@ public static ResentStatus fromString(String value) { } public static Order fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Order fromJson(JsonObject jsonObj) { Order obj = new Order(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.documentNumber = JsonUtil.getString(json, "document_number"); + obj.documentNumber = JsonUtil.getString(jsonObj, "document_number"); - obj.invoiceId = JsonUtil.getString(json, "invoice_id"); + obj.invoiceId = JsonUtil.getString(jsonObj, "invoice_id"); - obj.subscriptionId = JsonUtil.getString(json, "subscription_id"); + obj.subscriptionId = JsonUtil.getString(jsonObj, "subscription_id"); - obj.customerId = JsonUtil.getString(json, "customer_id"); + obj.customerId = JsonUtil.getString(jsonObj, "customer_id"); - obj.status = Status.fromString(JsonUtil.getString(json, "status")); + obj.status = Status.fromString(JsonUtil.getString(jsonObj, "status")); obj.cancellationReason = - CancellationReason.fromString(JsonUtil.getString(json, "cancellation_reason")); + CancellationReason.fromString(JsonUtil.getString(jsonObj, "cancellation_reason")); - obj.paymentStatus = PaymentStatus.fromString(JsonUtil.getString(json, "payment_status")); + obj.paymentStatus = PaymentStatus.fromString(JsonUtil.getString(jsonObj, "payment_status")); - obj.orderType = OrderType.fromString(JsonUtil.getString(json, "order_type")); + obj.orderType = OrderType.fromString(JsonUtil.getString(jsonObj, "order_type")); - obj.priceType = PriceType.fromString(JsonUtil.getString(json, "price_type")); + obj.priceType = PriceType.fromString(JsonUtil.getString(jsonObj, "price_type")); - obj.referenceId = JsonUtil.getString(json, "reference_id"); + obj.referenceId = JsonUtil.getString(jsonObj, "reference_id"); - obj.fulfillmentStatus = JsonUtil.getString(json, "fulfillment_status"); + obj.fulfillmentStatus = JsonUtil.getString(jsonObj, "fulfillment_status"); - obj.orderDate = JsonUtil.getTimestamp(json, "order_date"); + obj.orderDate = JsonUtil.getTimestamp(jsonObj, "order_date"); - obj.shippingDate = JsonUtil.getTimestamp(json, "shipping_date"); + obj.shippingDate = JsonUtil.getTimestamp(jsonObj, "shipping_date"); - obj.note = JsonUtil.getString(json, "note"); + obj.note = JsonUtil.getString(jsonObj, "note"); - obj.trackingId = JsonUtil.getString(json, "tracking_id"); + obj.trackingId = JsonUtil.getString(jsonObj, "tracking_id"); - obj.trackingUrl = JsonUtil.getString(json, "tracking_url"); + obj.trackingUrl = JsonUtil.getString(jsonObj, "tracking_url"); - obj.batchId = JsonUtil.getString(json, "batch_id"); + obj.batchId = JsonUtil.getString(jsonObj, "batch_id"); - obj.createdBy = JsonUtil.getString(json, "created_by"); + obj.createdBy = JsonUtil.getString(jsonObj, "created_by"); - obj.shipmentCarrier = JsonUtil.getString(json, "shipment_carrier"); + obj.shipmentCarrier = JsonUtil.getString(jsonObj, "shipment_carrier"); - obj.invoiceRoundOffAmount = JsonUtil.getLong(json, "invoice_round_off_amount"); + obj.invoiceRoundOffAmount = JsonUtil.getLong(jsonObj, "invoice_round_off_amount"); - obj.tax = JsonUtil.getLong(json, "tax"); + obj.tax = JsonUtil.getLong(jsonObj, "tax"); - obj.amountPaid = JsonUtil.getLong(json, "amount_paid"); + obj.amountPaid = JsonUtil.getLong(jsonObj, "amount_paid"); - obj.amountAdjusted = JsonUtil.getLong(json, "amount_adjusted"); + obj.amountAdjusted = JsonUtil.getLong(jsonObj, "amount_adjusted"); - obj.refundableCreditsIssued = JsonUtil.getLong(json, "refundable_credits_issued"); + obj.refundableCreditsIssued = JsonUtil.getLong(jsonObj, "refundable_credits_issued"); - obj.refundableCredits = JsonUtil.getLong(json, "refundable_credits"); + obj.refundableCredits = JsonUtil.getLong(jsonObj, "refundable_credits"); - obj.roundingAdjustement = JsonUtil.getLong(json, "rounding_adjustement"); + obj.roundingAdjustement = JsonUtil.getLong(jsonObj, "rounding_adjustement"); - obj.paidOn = JsonUtil.getTimestamp(json, "paid_on"); + obj.paidOn = JsonUtil.getTimestamp(jsonObj, "paid_on"); - obj.shippingCutOffDate = JsonUtil.getTimestamp(json, "shipping_cut_off_date"); + obj.shippingCutOffDate = JsonUtil.getTimestamp(jsonObj, "shipping_cut_off_date"); - obj.createdAt = JsonUtil.getTimestamp(json, "created_at"); + obj.createdAt = JsonUtil.getTimestamp(jsonObj, "created_at"); - obj.statusUpdateAt = JsonUtil.getTimestamp(json, "status_update_at"); + obj.statusUpdateAt = JsonUtil.getTimestamp(jsonObj, "status_update_at"); - obj.deliveredAt = JsonUtil.getTimestamp(json, "delivered_at"); + obj.deliveredAt = JsonUtil.getTimestamp(jsonObj, "delivered_at"); - obj.shippedAt = JsonUtil.getTimestamp(json, "shipped_at"); + obj.shippedAt = JsonUtil.getTimestamp(jsonObj, "shipped_at"); - obj.resourceVersion = JsonUtil.getLong(json, "resource_version"); + obj.resourceVersion = JsonUtil.getLong(jsonObj, "resource_version"); - obj.updatedAt = JsonUtil.getTimestamp(json, "updated_at"); + obj.updatedAt = JsonUtil.getTimestamp(jsonObj, "updated_at"); - obj.cancelledAt = JsonUtil.getTimestamp(json, "cancelled_at"); + obj.cancelledAt = JsonUtil.getTimestamp(jsonObj, "cancelled_at"); - obj.resentStatus = ResentStatus.fromString(JsonUtil.getString(json, "resent_status")); + obj.resentStatus = ResentStatus.fromString(JsonUtil.getString(jsonObj, "resent_status")); - obj.isResent = JsonUtil.getBoolean(json, "is_resent"); + obj.isResent = JsonUtil.getBoolean(jsonObj, "is_resent"); - obj.originalOrderId = JsonUtil.getString(json, "original_order_id"); + obj.originalOrderId = JsonUtil.getString(jsonObj, "original_order_id"); - obj.discount = JsonUtil.getLong(json, "discount"); + obj.discount = JsonUtil.getLong(jsonObj, "discount"); - obj.subTotal = JsonUtil.getLong(json, "sub_total"); + obj.subTotal = JsonUtil.getLong(jsonObj, "sub_total"); - obj.total = JsonUtil.getLong(json, "total"); + obj.total = JsonUtil.getLong(jsonObj, "total"); - obj.deleted = JsonUtil.getBoolean(json, "deleted"); + obj.deleted = JsonUtil.getBoolean(jsonObj, "deleted"); - obj.currencyCode = JsonUtil.getString(json, "currency_code"); + obj.currencyCode = JsonUtil.getString(jsonObj, "currency_code"); - obj.isGifted = JsonUtil.getBoolean(json, "is_gifted"); + obj.isGifted = JsonUtil.getBoolean(jsonObj, "is_gifted"); - obj.giftNote = JsonUtil.getString(json, "gift_note"); + obj.giftNote = JsonUtil.getString(jsonObj, "gift_note"); - obj.giftId = JsonUtil.getString(json, "gift_id"); + obj.giftId = JsonUtil.getString(jsonObj, "gift_id"); - obj.resendReason = JsonUtil.getString(json, "resend_reason"); + obj.resendReason = JsonUtil.getString(jsonObj, "resend_reason"); - obj.businessEntityId = JsonUtil.getString(json, "business_entity_id"); + obj.businessEntityId = JsonUtil.getString(jsonObj, "business_entity_id"); obj.orderLineItems = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "order_line_items")).stream() - .map(OrderLineItems::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "order_line_items"), OrderLineItems::fromJson); - String __shippingAddressJson = JsonUtil.getObject(json, "shipping_address"); - if (__shippingAddressJson != null) { - obj.shippingAddress = ShippingAddress.fromJson(__shippingAddressJson); + JsonObject __shippingAddressObj = JsonUtil.getJsonObject(jsonObj, "shipping_address"); + if (__shippingAddressObj != null) { + obj.shippingAddress = ShippingAddress.fromJson(__shippingAddressObj); } - String __billingAddressJson = JsonUtil.getObject(json, "billing_address"); - if (__billingAddressJson != null) { - obj.billingAddress = BillingAddress.fromJson(__billingAddressJson); + JsonObject __billingAddressObj = JsonUtil.getJsonObject(jsonObj, "billing_address"); + if (__billingAddressObj != null) { + obj.billingAddress = BillingAddress.fromJson(__billingAddressObj); } obj.lineItemTaxes = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "line_item_taxes")).stream() - .map(LineItemTaxes::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "line_item_taxes"), LineItemTaxes::fromJson); obj.lineItemDiscounts = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "line_item_discounts")).stream() - .map(LineItemDiscounts::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "line_item_discounts"), LineItemDiscounts::fromJson); obj.linkedCreditNotes = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "linked_credit_notes")).stream() - .map(LinkedCreditNotes::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "linked_credit_notes"), LinkedCreditNotes::fromJson); obj.resentOrders = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "resent_orders")).stream() - .map(ResentOrders::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "resent_orders"), ResentOrders::fromJson); return obj; } @@ -1073,47 +1072,51 @@ public static EntityType fromString(String value) { } public static OrderLineItems fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static OrderLineItems fromJson(JsonObject jsonObj) { OrderLineItems obj = new OrderLineItems(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.invoiceId = JsonUtil.getString(json, "invoice_id"); + obj.invoiceId = JsonUtil.getString(jsonObj, "invoice_id"); - obj.invoiceLineItemId = JsonUtil.getString(json, "invoice_line_item_id"); + obj.invoiceLineItemId = JsonUtil.getString(jsonObj, "invoice_line_item_id"); - obj.unitPrice = JsonUtil.getLong(json, "unit_price"); + obj.unitPrice = JsonUtil.getLong(jsonObj, "unit_price"); - obj.description = JsonUtil.getString(json, "description"); + obj.description = JsonUtil.getString(jsonObj, "description"); - obj.amount = JsonUtil.getLong(json, "amount"); + obj.amount = JsonUtil.getLong(jsonObj, "amount"); - obj.fulfillmentQuantity = JsonUtil.getInteger(json, "fulfillment_quantity"); + obj.fulfillmentQuantity = JsonUtil.getInteger(jsonObj, "fulfillment_quantity"); - obj.fulfillmentAmount = JsonUtil.getLong(json, "fulfillment_amount"); + obj.fulfillmentAmount = JsonUtil.getLong(jsonObj, "fulfillment_amount"); - obj.taxAmount = JsonUtil.getLong(json, "tax_amount"); + obj.taxAmount = JsonUtil.getLong(jsonObj, "tax_amount"); - obj.amountPaid = JsonUtil.getLong(json, "amount_paid"); + obj.amountPaid = JsonUtil.getLong(jsonObj, "amount_paid"); - obj.amountAdjusted = JsonUtil.getLong(json, "amount_adjusted"); + obj.amountAdjusted = JsonUtil.getLong(jsonObj, "amount_adjusted"); - obj.refundableCreditsIssued = JsonUtil.getLong(json, "refundable_credits_issued"); + obj.refundableCreditsIssued = JsonUtil.getLong(jsonObj, "refundable_credits_issued"); - obj.refundableCredits = JsonUtil.getLong(json, "refundable_credits"); + obj.refundableCredits = JsonUtil.getLong(jsonObj, "refundable_credits"); - obj.isShippable = JsonUtil.getBoolean(json, "is_shippable"); + obj.isShippable = JsonUtil.getBoolean(jsonObj, "is_shippable"); - obj.sku = JsonUtil.getString(json, "sku"); + obj.sku = JsonUtil.getString(jsonObj, "sku"); - obj.status = Status.fromString(JsonUtil.getString(json, "status")); + obj.status = Status.fromString(JsonUtil.getString(jsonObj, "status")); - obj.entityType = EntityType.fromString(JsonUtil.getString(json, "entity_type")); + obj.entityType = EntityType.fromString(JsonUtil.getString(jsonObj, "entity_type")); - obj.itemLevelDiscountAmount = JsonUtil.getLong(json, "item_level_discount_amount"); + obj.itemLevelDiscountAmount = JsonUtil.getLong(jsonObj, "item_level_discount_amount"); - obj.discountAmount = JsonUtil.getLong(json, "discount_amount"); + obj.discountAmount = JsonUtil.getLong(jsonObj, "discount_amount"); - obj.entityId = JsonUtil.getString(json, "entity_id"); + obj.entityId = JsonUtil.getString(jsonObj, "entity_id"); return obj; } @@ -1325,36 +1328,40 @@ public static ValidationStatus fromString(String value) { } public static ShippingAddress fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static ShippingAddress fromJson(JsonObject jsonObj) { ShippingAddress obj = new ShippingAddress(); - obj.firstName = JsonUtil.getString(json, "first_name"); + obj.firstName = JsonUtil.getString(jsonObj, "first_name"); - obj.lastName = JsonUtil.getString(json, "last_name"); + obj.lastName = JsonUtil.getString(jsonObj, "last_name"); - obj.email = JsonUtil.getString(json, "email"); + obj.email = JsonUtil.getString(jsonObj, "email"); - obj.company = JsonUtil.getString(json, "company"); + obj.company = JsonUtil.getString(jsonObj, "company"); - obj.phone = JsonUtil.getString(json, "phone"); + obj.phone = JsonUtil.getString(jsonObj, "phone"); - obj.line1 = JsonUtil.getString(json, "line1"); + obj.line1 = JsonUtil.getString(jsonObj, "line1"); - obj.line2 = JsonUtil.getString(json, "line2"); + obj.line2 = JsonUtil.getString(jsonObj, "line2"); - obj.line3 = JsonUtil.getString(json, "line3"); + obj.line3 = JsonUtil.getString(jsonObj, "line3"); - obj.city = JsonUtil.getString(json, "city"); + obj.city = JsonUtil.getString(jsonObj, "city"); - obj.stateCode = JsonUtil.getString(json, "state_code"); + obj.stateCode = JsonUtil.getString(jsonObj, "state_code"); - obj.state = JsonUtil.getString(json, "state"); + obj.state = JsonUtil.getString(jsonObj, "state"); - obj.country = JsonUtil.getString(json, "country"); + obj.country = JsonUtil.getString(jsonObj, "country"); - obj.zip = JsonUtil.getString(json, "zip"); + obj.zip = JsonUtil.getString(jsonObj, "zip"); obj.validationStatus = - ValidationStatus.fromString(JsonUtil.getString(json, "validation_status")); + ValidationStatus.fromString(JsonUtil.getString(jsonObj, "validation_status")); return obj; } @@ -1542,36 +1549,40 @@ public static ValidationStatus fromString(String value) { } public static BillingAddress fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static BillingAddress fromJson(JsonObject jsonObj) { BillingAddress obj = new BillingAddress(); - obj.firstName = JsonUtil.getString(json, "first_name"); + obj.firstName = JsonUtil.getString(jsonObj, "first_name"); - obj.lastName = JsonUtil.getString(json, "last_name"); + obj.lastName = JsonUtil.getString(jsonObj, "last_name"); - obj.email = JsonUtil.getString(json, "email"); + obj.email = JsonUtil.getString(jsonObj, "email"); - obj.company = JsonUtil.getString(json, "company"); + obj.company = JsonUtil.getString(jsonObj, "company"); - obj.phone = JsonUtil.getString(json, "phone"); + obj.phone = JsonUtil.getString(jsonObj, "phone"); - obj.line1 = JsonUtil.getString(json, "line1"); + obj.line1 = JsonUtil.getString(jsonObj, "line1"); - obj.line2 = JsonUtil.getString(json, "line2"); + obj.line2 = JsonUtil.getString(jsonObj, "line2"); - obj.line3 = JsonUtil.getString(json, "line3"); + obj.line3 = JsonUtil.getString(jsonObj, "line3"); - obj.city = JsonUtil.getString(json, "city"); + obj.city = JsonUtil.getString(jsonObj, "city"); - obj.stateCode = JsonUtil.getString(json, "state_code"); + obj.stateCode = JsonUtil.getString(jsonObj, "state_code"); - obj.state = JsonUtil.getString(json, "state"); + obj.state = JsonUtil.getString(jsonObj, "state"); - obj.country = JsonUtil.getString(json, "country"); + obj.country = JsonUtil.getString(jsonObj, "country"); - obj.zip = JsonUtil.getString(json, "zip"); + obj.zip = JsonUtil.getString(jsonObj, "zip"); obj.validationStatus = - ValidationStatus.fromString(JsonUtil.getString(json, "validation_status")); + ValidationStatus.fromString(JsonUtil.getString(jsonObj, "validation_status")); return obj; } @@ -1772,37 +1783,41 @@ public static TaxJurisType fromString(String value) { } public static LineItemTaxes fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static LineItemTaxes fromJson(JsonObject jsonObj) { LineItemTaxes obj = new LineItemTaxes(); - obj.lineItemId = JsonUtil.getString(json, "line_item_id"); + obj.lineItemId = JsonUtil.getString(jsonObj, "line_item_id"); - obj.taxName = JsonUtil.getString(json, "tax_name"); + obj.taxName = JsonUtil.getString(jsonObj, "tax_name"); - obj.taxRate = JsonUtil.getDouble(json, "tax_rate"); + obj.taxRate = JsonUtil.getDouble(jsonObj, "tax_rate"); - obj.dateTo = JsonUtil.getTimestamp(json, "date_to"); + obj.dateTo = JsonUtil.getTimestamp(jsonObj, "date_to"); - obj.dateFrom = JsonUtil.getTimestamp(json, "date_from"); + obj.dateFrom = JsonUtil.getTimestamp(jsonObj, "date_from"); - obj.proratedTaxableAmount = JsonUtil.getBigDecimal(json, "prorated_taxable_amount"); + obj.proratedTaxableAmount = JsonUtil.getBigDecimal(jsonObj, "prorated_taxable_amount"); - obj.isPartialTaxApplied = JsonUtil.getBoolean(json, "is_partial_tax_applied"); + obj.isPartialTaxApplied = JsonUtil.getBoolean(jsonObj, "is_partial_tax_applied"); - obj.isNonComplianceTax = JsonUtil.getBoolean(json, "is_non_compliance_tax"); + obj.isNonComplianceTax = JsonUtil.getBoolean(jsonObj, "is_non_compliance_tax"); - obj.taxableAmount = JsonUtil.getLong(json, "taxable_amount"); + obj.taxableAmount = JsonUtil.getLong(jsonObj, "taxable_amount"); - obj.taxAmount = JsonUtil.getLong(json, "tax_amount"); + obj.taxAmount = JsonUtil.getLong(jsonObj, "tax_amount"); - obj.taxJurisType = TaxJurisType.fromString(JsonUtil.getString(json, "tax_juris_type")); + obj.taxJurisType = TaxJurisType.fromString(JsonUtil.getString(jsonObj, "tax_juris_type")); - obj.taxJurisName = JsonUtil.getString(json, "tax_juris_name"); + obj.taxJurisName = JsonUtil.getString(jsonObj, "tax_juris_name"); - obj.taxJurisCode = JsonUtil.getString(json, "tax_juris_code"); + obj.taxJurisCode = JsonUtil.getString(jsonObj, "tax_juris_code"); - obj.taxAmountInLocalCurrency = JsonUtil.getLong(json, "tax_amount_in_local_currency"); + obj.taxAmountInLocalCurrency = JsonUtil.getLong(jsonObj, "tax_amount_in_local_currency"); - obj.localCurrencyCode = JsonUtil.getString(json, "local_currency_code"); + obj.localCurrencyCode = JsonUtil.getString(jsonObj, "local_currency_code"); return obj; } @@ -1956,17 +1971,21 @@ public static DiscountType fromString(String value) { } public static LineItemDiscounts fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static LineItemDiscounts fromJson(JsonObject jsonObj) { LineItemDiscounts obj = new LineItemDiscounts(); - obj.lineItemId = JsonUtil.getString(json, "line_item_id"); + obj.lineItemId = JsonUtil.getString(jsonObj, "line_item_id"); - obj.discountType = DiscountType.fromString(JsonUtil.getString(json, "discount_type")); + obj.discountType = DiscountType.fromString(JsonUtil.getString(jsonObj, "discount_type")); - obj.couponId = JsonUtil.getString(json, "coupon_id"); + obj.couponId = JsonUtil.getString(jsonObj, "coupon_id"); - obj.entityId = JsonUtil.getString(json, "entity_id"); + obj.entityId = JsonUtil.getString(jsonObj, "entity_id"); - obj.discountAmount = JsonUtil.getLong(json, "discount_amount"); + obj.discountAmount = JsonUtil.getLong(jsonObj, "discount_amount"); return obj; } @@ -2103,19 +2122,23 @@ public static Status fromString(String value) { } public static LinkedCreditNotes fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static LinkedCreditNotes fromJson(JsonObject jsonObj) { LinkedCreditNotes obj = new LinkedCreditNotes(); - obj.amount = JsonUtil.getLong(json, "amount"); + obj.amount = JsonUtil.getLong(jsonObj, "amount"); - obj.type = Type.fromString(JsonUtil.getString(json, "type")); + obj.type = Type.fromString(JsonUtil.getString(jsonObj, "type")); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.status = Status.fromString(JsonUtil.getString(json, "status")); + obj.status = Status.fromString(JsonUtil.getString(jsonObj, "status")); - obj.amountAdjusted = JsonUtil.getLong(json, "amount_adjusted"); + obj.amountAdjusted = JsonUtil.getLong(jsonObj, "amount_adjusted"); - obj.amountRefunded = JsonUtil.getLong(json, "amount_refunded"); + obj.amountRefunded = JsonUtil.getLong(jsonObj, "amount_refunded"); return obj; } @@ -2178,13 +2201,17 @@ public Long getAmount() { } public static ResentOrders fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static ResentOrders fromJson(JsonObject jsonObj) { ResentOrders obj = new ResentOrders(); - obj.orderId = JsonUtil.getString(json, "order_id"); + obj.orderId = JsonUtil.getString(jsonObj, "order_id"); - obj.reason = JsonUtil.getString(json, "reason"); + obj.reason = JsonUtil.getString(jsonObj, "reason"); - obj.amount = JsonUtil.getLong(json, "amount"); + obj.amount = JsonUtil.getLong(jsonObj, "amount"); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/order/responses/AssignOrderNumberResponse.java b/src/main/java/com/chargebee/v4/models/order/responses/AssignOrderNumberResponse.java index fe44fd63..6657d6a5 100644 --- a/src/main/java/com/chargebee/v4/models/order/responses/AssignOrderNumberResponse.java +++ b/src/main/java/com/chargebee/v4/models/order/responses/AssignOrderNumberResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static AssignOrderNumberResponse fromJson(String json) { /** Parse JSON response into AssignOrderNumberResponse object with HTTP response. */ public static AssignOrderNumberResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __orderJson = JsonUtil.getObject(json, "order"); - if (__orderJson != null) { - builder.order(Order.fromJson(__orderJson)); + JsonObject __orderObj = JsonUtil.getJsonObject(jsonObj, "order"); + if (__orderObj != null) { + builder.order(Order.fromJson(__orderObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/order/responses/ImportOrderResponse.java b/src/main/java/com/chargebee/v4/models/order/responses/ImportOrderResponse.java index b4cf4010..7f4ecf5d 100644 --- a/src/main/java/com/chargebee/v4/models/order/responses/ImportOrderResponse.java +++ b/src/main/java/com/chargebee/v4/models/order/responses/ImportOrderResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** Immutable response object for ImportOrder operation. Contains the response data from the API. */ @@ -24,11 +25,12 @@ public static ImportOrderResponse fromJson(String json) { /** Parse JSON response into ImportOrderResponse object with HTTP response. */ public static ImportOrderResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __orderJson = JsonUtil.getObject(json, "order"); - if (__orderJson != null) { - builder.order(Order.fromJson(__orderJson)); + JsonObject __orderObj = JsonUtil.getJsonObject(jsonObj, "order"); + if (__orderObj != null) { + builder.order(Order.fromJson(__orderObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/order/responses/OrderCancelResponse.java b/src/main/java/com/chargebee/v4/models/order/responses/OrderCancelResponse.java index 1a6c737e..148677d6 100644 --- a/src/main/java/com/chargebee/v4/models/order/responses/OrderCancelResponse.java +++ b/src/main/java/com/chargebee/v4/models/order/responses/OrderCancelResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** Immutable response object for OrderCancel operation. Contains the response data from the API. */ @@ -24,11 +25,12 @@ public static OrderCancelResponse fromJson(String json) { /** Parse JSON response into OrderCancelResponse object with HTTP response. */ public static OrderCancelResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __orderJson = JsonUtil.getObject(json, "order"); - if (__orderJson != null) { - builder.order(Order.fromJson(__orderJson)); + JsonObject __orderObj = JsonUtil.getJsonObject(jsonObj, "order"); + if (__orderObj != null) { + builder.order(Order.fromJson(__orderObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/order/responses/OrderCreateRefundableCreditNoteResponse.java b/src/main/java/com/chargebee/v4/models/order/responses/OrderCreateRefundableCreditNoteResponse.java index 160670a2..42f67f74 100644 --- a/src/main/java/com/chargebee/v4/models/order/responses/OrderCreateRefundableCreditNoteResponse.java +++ b/src/main/java/com/chargebee/v4/models/order/responses/OrderCreateRefundableCreditNoteResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -28,11 +29,12 @@ public static OrderCreateRefundableCreditNoteResponse fromJson(String json) { public static OrderCreateRefundableCreditNoteResponse fromJson( String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __orderJson = JsonUtil.getObject(json, "order"); - if (__orderJson != null) { - builder.order(Order.fromJson(__orderJson)); + JsonObject __orderObj = JsonUtil.getJsonObject(jsonObj, "order"); + if (__orderObj != null) { + builder.order(Order.fromJson(__orderObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/order/responses/OrderCreateResponse.java b/src/main/java/com/chargebee/v4/models/order/responses/OrderCreateResponse.java index de6a300f..73130528 100644 --- a/src/main/java/com/chargebee/v4/models/order/responses/OrderCreateResponse.java +++ b/src/main/java/com/chargebee/v4/models/order/responses/OrderCreateResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** Immutable response object for OrderCreate operation. Contains the response data from the API. */ @@ -24,11 +25,12 @@ public static OrderCreateResponse fromJson(String json) { /** Parse JSON response into OrderCreateResponse object with HTTP response. */ public static OrderCreateResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __orderJson = JsonUtil.getObject(json, "order"); - if (__orderJson != null) { - builder.order(Order.fromJson(__orderJson)); + JsonObject __orderObj = JsonUtil.getJsonObject(jsonObj, "order"); + if (__orderObj != null) { + builder.order(Order.fromJson(__orderObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/order/responses/OrderDeleteResponse.java b/src/main/java/com/chargebee/v4/models/order/responses/OrderDeleteResponse.java index 8e7642eb..49c7a426 100644 --- a/src/main/java/com/chargebee/v4/models/order/responses/OrderDeleteResponse.java +++ b/src/main/java/com/chargebee/v4/models/order/responses/OrderDeleteResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** Immutable response object for OrderDelete operation. Contains the response data from the API. */ @@ -24,11 +25,12 @@ public static OrderDeleteResponse fromJson(String json) { /** Parse JSON response into OrderDeleteResponse object with HTTP response. */ public static OrderDeleteResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __orderJson = JsonUtil.getObject(json, "order"); - if (__orderJson != null) { - builder.order(Order.fromJson(__orderJson)); + JsonObject __orderObj = JsonUtil.getJsonObject(jsonObj, "order"); + if (__orderObj != null) { + builder.order(Order.fromJson(__orderObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/order/responses/OrderListResponse.java b/src/main/java/com/chargebee/v4/models/order/responses/OrderListResponse.java index d8fcf640..a292ce66 100644 --- a/src/main/java/com/chargebee/v4/models/order/responses/OrderListResponse.java +++ b/src/main/java/com/chargebee/v4/models/order/responses/OrderListResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.exceptions.ChargebeeException; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; import com.chargebee.v4.services.OrderService; import com.chargebee.v4.models.order.params.OrderListParams; @@ -43,13 +44,12 @@ private OrderListResponse( */ public static OrderListResponse fromJson(String json) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(OrderListItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "list"), OrderListItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new OrderListResponse(list, nextOffset, null, null, null); } catch (Exception e) { @@ -64,13 +64,12 @@ public static OrderListResponse fromJson(String json) { public static OrderListResponse fromJson( String json, OrderService service, OrderListParams originalParams, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(OrderListItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "list"), OrderListItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new OrderListResponse(list, nextOffset, service, originalParams, httpResponse); } catch (Exception e) { @@ -170,11 +169,15 @@ public Order getOrder() { } public static OrderListItem fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static OrderListItem fromJson(JsonObject jsonObj) { OrderListItem item = new OrderListItem(); - String __orderJson = JsonUtil.getObject(json, "order"); - if (__orderJson != null) { - item.order = Order.fromJson(__orderJson); + JsonObject __orderObj = JsonUtil.getJsonObject(jsonObj, "order"); + if (__orderObj != null) { + item.order = Order.fromJson(__orderObj); } return item; diff --git a/src/main/java/com/chargebee/v4/models/order/responses/OrderReopenResponse.java b/src/main/java/com/chargebee/v4/models/order/responses/OrderReopenResponse.java index 17704d46..49c4764e 100644 --- a/src/main/java/com/chargebee/v4/models/order/responses/OrderReopenResponse.java +++ b/src/main/java/com/chargebee/v4/models/order/responses/OrderReopenResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** Immutable response object for OrderReopen operation. Contains the response data from the API. */ @@ -24,11 +25,12 @@ public static OrderReopenResponse fromJson(String json) { /** Parse JSON response into OrderReopenResponse object with HTTP response. */ public static OrderReopenResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __orderJson = JsonUtil.getObject(json, "order"); - if (__orderJson != null) { - builder.order(Order.fromJson(__orderJson)); + JsonObject __orderObj = JsonUtil.getJsonObject(jsonObj, "order"); + if (__orderObj != null) { + builder.order(Order.fromJson(__orderObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/order/responses/OrderResendResponse.java b/src/main/java/com/chargebee/v4/models/order/responses/OrderResendResponse.java index bf1f23d1..078620b3 100644 --- a/src/main/java/com/chargebee/v4/models/order/responses/OrderResendResponse.java +++ b/src/main/java/com/chargebee/v4/models/order/responses/OrderResendResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** Immutable response object for OrderResend operation. Contains the response data from the API. */ @@ -24,11 +25,12 @@ public static OrderResendResponse fromJson(String json) { /** Parse JSON response into OrderResendResponse object with HTTP response. */ public static OrderResendResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __orderJson = JsonUtil.getObject(json, "order"); - if (__orderJson != null) { - builder.order(Order.fromJson(__orderJson)); + JsonObject __orderObj = JsonUtil.getJsonObject(jsonObj, "order"); + if (__orderObj != null) { + builder.order(Order.fromJson(__orderObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/order/responses/OrderRetrieveResponse.java b/src/main/java/com/chargebee/v4/models/order/responses/OrderRetrieveResponse.java index c7f02c2c..5030990f 100644 --- a/src/main/java/com/chargebee/v4/models/order/responses/OrderRetrieveResponse.java +++ b/src/main/java/com/chargebee/v4/models/order/responses/OrderRetrieveResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static OrderRetrieveResponse fromJson(String json) { /** Parse JSON response into OrderRetrieveResponse object with HTTP response. */ public static OrderRetrieveResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __orderJson = JsonUtil.getObject(json, "order"); - if (__orderJson != null) { - builder.order(Order.fromJson(__orderJson)); + JsonObject __orderObj = JsonUtil.getJsonObject(jsonObj, "order"); + if (__orderObj != null) { + builder.order(Order.fromJson(__orderObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/order/responses/OrderUpdateResponse.java b/src/main/java/com/chargebee/v4/models/order/responses/OrderUpdateResponse.java index cf336227..bd471bec 100644 --- a/src/main/java/com/chargebee/v4/models/order/responses/OrderUpdateResponse.java +++ b/src/main/java/com/chargebee/v4/models/order/responses/OrderUpdateResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** Immutable response object for OrderUpdate operation. Contains the response data from the API. */ @@ -24,11 +25,12 @@ public static OrderUpdateResponse fromJson(String json) { /** Parse JSON response into OrderUpdateResponse object with HTTP response. */ public static OrderUpdateResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __orderJson = JsonUtil.getObject(json, "order"); - if (__orderJson != null) { - builder.order(Order.fromJson(__orderJson)); + JsonObject __orderObj = JsonUtil.getJsonObject(jsonObj, "order"); + if (__orderObj != null) { + builder.order(Order.fromJson(__orderObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/order/responses/OrdersForInvoiceResponse.java b/src/main/java/com/chargebee/v4/models/order/responses/OrdersForInvoiceResponse.java index f49e0970..1c237a83 100644 --- a/src/main/java/com/chargebee/v4/models/order/responses/OrdersForInvoiceResponse.java +++ b/src/main/java/com/chargebee/v4/models/order/responses/OrdersForInvoiceResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.exceptions.ChargebeeException; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; import com.chargebee.v4.services.OrderService; import com.chargebee.v4.models.order.params.OrdersForInvoiceParams; @@ -48,13 +49,13 @@ private OrdersForInvoiceResponse( */ public static OrdersForInvoiceResponse fromJson(String json) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(OrderOrdersForInvoiceItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "list"), OrderOrdersForInvoiceItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new OrdersForInvoiceResponse(list, nextOffset, null, null, null, null); } catch (Exception e) { @@ -73,13 +74,13 @@ public static OrdersForInvoiceResponse fromJson( String invoiceId, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(OrderOrdersForInvoiceItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "list"), OrderOrdersForInvoiceItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new OrdersForInvoiceResponse( list, nextOffset, invoiceId, service, originalParams, httpResponse); @@ -180,11 +181,15 @@ public Order getOrder() { } public static OrderOrdersForInvoiceItem fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static OrderOrdersForInvoiceItem fromJson(JsonObject jsonObj) { OrderOrdersForInvoiceItem item = new OrderOrdersForInvoiceItem(); - String __orderJson = JsonUtil.getObject(json, "order"); - if (__orderJson != null) { - item.order = Order.fromJson(__orderJson); + JsonObject __orderObj = JsonUtil.getJsonObject(jsonObj, "order"); + if (__orderObj != null) { + item.order = Order.fromJson(__orderObj); } return item; diff --git a/src/main/java/com/chargebee/v4/models/paymentIntent/PaymentIntent.java b/src/main/java/com/chargebee/v4/models/paymentIntent/PaymentIntent.java index b47c40c8..ee198cab 100644 --- a/src/main/java/com/chargebee/v4/models/paymentIntent/PaymentIntent.java +++ b/src/main/java/com/chargebee/v4/models/paymentIntent/PaymentIntent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.paymentIntent; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import java.sql.Timestamp; import java.util.List; @@ -232,52 +233,56 @@ public static PaymentMethodType fromString(String value) { } public static PaymentIntent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static PaymentIntent fromJson(JsonObject jsonObj) { PaymentIntent obj = new PaymentIntent(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.status = Status.fromString(JsonUtil.getString(json, "status")); + obj.status = Status.fromString(JsonUtil.getString(jsonObj, "status")); - obj.currencyCode = JsonUtil.getString(json, "currency_code"); + obj.currencyCode = JsonUtil.getString(jsonObj, "currency_code"); - obj.amount = JsonUtil.getLong(json, "amount"); + obj.amount = JsonUtil.getLong(jsonObj, "amount"); - obj.gatewayAccountId = JsonUtil.getString(json, "gateway_account_id"); + obj.gatewayAccountId = JsonUtil.getString(jsonObj, "gateway_account_id"); - obj.expiresAt = JsonUtil.getTimestamp(json, "expires_at"); + obj.expiresAt = JsonUtil.getTimestamp(jsonObj, "expires_at"); - obj.referenceId = JsonUtil.getString(json, "reference_id"); + obj.referenceId = JsonUtil.getString(jsonObj, "reference_id"); obj.paymentMethodType = - PaymentMethodType.fromString(JsonUtil.getString(json, "payment_method_type")); + PaymentMethodType.fromString(JsonUtil.getString(jsonObj, "payment_method_type")); - obj.successUrl = JsonUtil.getString(json, "success_url"); + obj.successUrl = JsonUtil.getString(jsonObj, "success_url"); - obj.failureUrl = JsonUtil.getString(json, "failure_url"); + obj.failureUrl = JsonUtil.getString(jsonObj, "failure_url"); - obj.createdAt = JsonUtil.getTimestamp(json, "created_at"); + obj.createdAt = JsonUtil.getTimestamp(jsonObj, "created_at"); - obj.modifiedAt = JsonUtil.getTimestamp(json, "modified_at"); + obj.modifiedAt = JsonUtil.getTimestamp(jsonObj, "modified_at"); - obj.resourceVersion = JsonUtil.getLong(json, "resource_version"); + obj.resourceVersion = JsonUtil.getLong(jsonObj, "resource_version"); - obj.updatedAt = JsonUtil.getTimestamp(json, "updated_at"); + obj.updatedAt = JsonUtil.getTimestamp(jsonObj, "updated_at"); - obj.customerId = JsonUtil.getString(json, "customer_id"); + obj.customerId = JsonUtil.getString(jsonObj, "customer_id"); - obj.gateway = JsonUtil.getString(json, "gateway"); + obj.gateway = JsonUtil.getString(jsonObj, "gateway"); - obj.businessEntityId = JsonUtil.getString(json, "business_entity_id"); + obj.businessEntityId = JsonUtil.getString(jsonObj, "business_entity_id"); - String __activePaymentAttemptJson = JsonUtil.getObject(json, "active_payment_attempt"); - if (__activePaymentAttemptJson != null) { - obj.activePaymentAttempt = ActivePaymentAttempt.fromJson(__activePaymentAttemptJson); + JsonObject __activePaymentAttemptObj = + JsonUtil.getJsonObject(jsonObj, "active_payment_attempt"); + if (__activePaymentAttemptObj != null) { + obj.activePaymentAttempt = ActivePaymentAttempt.fromJson(__activePaymentAttemptObj); } obj.paymentAttempts = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "payment_attempts")).stream() - .map(PaymentAttempts::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "payment_attempts"), PaymentAttempts::fromJson); return obj; } @@ -560,30 +565,34 @@ public static PaymentMethodType fromString(String value) { } public static ActivePaymentAttempt fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static ActivePaymentAttempt fromJson(JsonObject jsonObj) { ActivePaymentAttempt obj = new ActivePaymentAttempt(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.status = Status.fromString(JsonUtil.getString(json, "status")); + obj.status = Status.fromString(JsonUtil.getString(jsonObj, "status")); obj.paymentMethodType = - PaymentMethodType.fromString(JsonUtil.getString(json, "payment_method_type")); + PaymentMethodType.fromString(JsonUtil.getString(jsonObj, "payment_method_type")); - obj.idAtGateway = JsonUtil.getString(json, "id_at_gateway"); + obj.idAtGateway = JsonUtil.getString(jsonObj, "id_at_gateway"); - obj.errorCode = JsonUtil.getString(json, "error_code"); + obj.errorCode = JsonUtil.getString(jsonObj, "error_code"); - obj.errorText = JsonUtil.getString(json, "error_text"); + obj.errorText = JsonUtil.getString(jsonObj, "error_text"); - obj.checkoutDetails = JsonUtil.getString(json, "checkout_details"); + obj.checkoutDetails = JsonUtil.getString(jsonObj, "checkout_details"); - obj.createdAt = JsonUtil.getTimestamp(json, "created_at"); + obj.createdAt = JsonUtil.getTimestamp(jsonObj, "created_at"); - obj.modifiedAt = JsonUtil.getTimestamp(json, "modified_at"); + obj.modifiedAt = JsonUtil.getTimestamp(jsonObj, "modified_at"); - String __errorDetailJson = JsonUtil.getObject(json, "error_detail"); - if (__errorDetailJson != null) { - obj.errorDetail = ErrorDetail.fromJson(__errorDetailJson); + JsonObject __errorDetailObj = JsonUtil.getJsonObject(jsonObj, "error_detail"); + if (__errorDetailObj != null) { + obj.errorDetail = ErrorDetail.fromJson(__errorDetailObj); } return obj; @@ -728,37 +737,41 @@ public String getProcessorAdviceCode() { } public static ErrorDetail fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static ErrorDetail fromJson(JsonObject jsonObj) { ErrorDetail obj = new ErrorDetail(); - obj.requestId = JsonUtil.getString(json, "request_id"); + obj.requestId = JsonUtil.getString(jsonObj, "request_id"); - obj.errorCategory = JsonUtil.getString(json, "error_category"); + obj.errorCategory = JsonUtil.getString(jsonObj, "error_category"); - obj.errorCode = JsonUtil.getString(json, "error_code"); + obj.errorCode = JsonUtil.getString(jsonObj, "error_code"); - obj.errorMessage = JsonUtil.getString(json, "error_message"); + obj.errorMessage = JsonUtil.getString(jsonObj, "error_message"); - obj.declineCode = JsonUtil.getString(json, "decline_code"); + obj.declineCode = JsonUtil.getString(jsonObj, "decline_code"); - obj.declineMessage = JsonUtil.getString(json, "decline_message"); + obj.declineMessage = JsonUtil.getString(jsonObj, "decline_message"); - obj.networkErrorCode = JsonUtil.getString(json, "network_error_code"); + obj.networkErrorCode = JsonUtil.getString(jsonObj, "network_error_code"); - obj.networkErrorMessage = JsonUtil.getString(json, "network_error_message"); + obj.networkErrorMessage = JsonUtil.getString(jsonObj, "network_error_message"); - obj.errorField = JsonUtil.getString(json, "error_field"); + obj.errorField = JsonUtil.getString(jsonObj, "error_field"); - obj.recommendationCode = JsonUtil.getString(json, "recommendation_code"); + obj.recommendationCode = JsonUtil.getString(jsonObj, "recommendation_code"); - obj.recommendationMessage = JsonUtil.getString(json, "recommendation_message"); + obj.recommendationMessage = JsonUtil.getString(jsonObj, "recommendation_message"); - obj.processorErrorCode = JsonUtil.getString(json, "processor_error_code"); + obj.processorErrorCode = JsonUtil.getString(jsonObj, "processor_error_code"); - obj.processorErrorMessage = JsonUtil.getString(json, "processor_error_message"); + obj.processorErrorMessage = JsonUtil.getString(jsonObj, "processor_error_message"); - obj.errorCauseId = JsonUtil.getString(json, "error_cause_id"); + obj.errorCauseId = JsonUtil.getString(jsonObj, "error_cause_id"); - obj.processorAdviceCode = JsonUtil.getString(json, "processor_advice_code"); + obj.processorAdviceCode = JsonUtil.getString(jsonObj, "processor_advice_code"); return obj; } @@ -1027,30 +1040,34 @@ public static PaymentMethodType fromString(String value) { } public static PaymentAttempts fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static PaymentAttempts fromJson(JsonObject jsonObj) { PaymentAttempts obj = new PaymentAttempts(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.status = Status.fromString(JsonUtil.getString(json, "status")); + obj.status = Status.fromString(JsonUtil.getString(jsonObj, "status")); obj.paymentMethodType = - PaymentMethodType.fromString(JsonUtil.getString(json, "payment_method_type")); + PaymentMethodType.fromString(JsonUtil.getString(jsonObj, "payment_method_type")); - obj.idAtGateway = JsonUtil.getString(json, "id_at_gateway"); + obj.idAtGateway = JsonUtil.getString(jsonObj, "id_at_gateway"); - obj.errorCode = JsonUtil.getString(json, "error_code"); + obj.errorCode = JsonUtil.getString(jsonObj, "error_code"); - obj.errorText = JsonUtil.getString(json, "error_text"); + obj.errorText = JsonUtil.getString(jsonObj, "error_text"); - obj.checkoutDetails = JsonUtil.getString(json, "checkout_details"); + obj.checkoutDetails = JsonUtil.getString(jsonObj, "checkout_details"); - obj.createdAt = JsonUtil.getTimestamp(json, "created_at"); + obj.createdAt = JsonUtil.getTimestamp(jsonObj, "created_at"); - obj.modifiedAt = JsonUtil.getTimestamp(json, "modified_at"); + obj.modifiedAt = JsonUtil.getTimestamp(jsonObj, "modified_at"); - String __errorDetailJson = JsonUtil.getObject(json, "error_detail"); - if (__errorDetailJson != null) { - obj.errorDetail = ErrorDetail.fromJson(__errorDetailJson); + JsonObject __errorDetailObj = JsonUtil.getJsonObject(jsonObj, "error_detail"); + if (__errorDetailObj != null) { + obj.errorDetail = ErrorDetail.fromJson(__errorDetailObj); } return obj; @@ -1195,37 +1212,41 @@ public String getProcessorAdviceCode() { } public static ErrorDetail fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static ErrorDetail fromJson(JsonObject jsonObj) { ErrorDetail obj = new ErrorDetail(); - obj.requestId = JsonUtil.getString(json, "request_id"); + obj.requestId = JsonUtil.getString(jsonObj, "request_id"); - obj.errorCategory = JsonUtil.getString(json, "error_category"); + obj.errorCategory = JsonUtil.getString(jsonObj, "error_category"); - obj.errorCode = JsonUtil.getString(json, "error_code"); + obj.errorCode = JsonUtil.getString(jsonObj, "error_code"); - obj.errorMessage = JsonUtil.getString(json, "error_message"); + obj.errorMessage = JsonUtil.getString(jsonObj, "error_message"); - obj.declineCode = JsonUtil.getString(json, "decline_code"); + obj.declineCode = JsonUtil.getString(jsonObj, "decline_code"); - obj.declineMessage = JsonUtil.getString(json, "decline_message"); + obj.declineMessage = JsonUtil.getString(jsonObj, "decline_message"); - obj.networkErrorCode = JsonUtil.getString(json, "network_error_code"); + obj.networkErrorCode = JsonUtil.getString(jsonObj, "network_error_code"); - obj.networkErrorMessage = JsonUtil.getString(json, "network_error_message"); + obj.networkErrorMessage = JsonUtil.getString(jsonObj, "network_error_message"); - obj.errorField = JsonUtil.getString(json, "error_field"); + obj.errorField = JsonUtil.getString(jsonObj, "error_field"); - obj.recommendationCode = JsonUtil.getString(json, "recommendation_code"); + obj.recommendationCode = JsonUtil.getString(jsonObj, "recommendation_code"); - obj.recommendationMessage = JsonUtil.getString(json, "recommendation_message"); + obj.recommendationMessage = JsonUtil.getString(jsonObj, "recommendation_message"); - obj.processorErrorCode = JsonUtil.getString(json, "processor_error_code"); + obj.processorErrorCode = JsonUtil.getString(jsonObj, "processor_error_code"); - obj.processorErrorMessage = JsonUtil.getString(json, "processor_error_message"); + obj.processorErrorMessage = JsonUtil.getString(jsonObj, "processor_error_message"); - obj.errorCauseId = JsonUtil.getString(json, "error_cause_id"); + obj.errorCauseId = JsonUtil.getString(jsonObj, "error_cause_id"); - obj.processorAdviceCode = JsonUtil.getString(json, "processor_advice_code"); + obj.processorAdviceCode = JsonUtil.getString(jsonObj, "processor_advice_code"); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/paymentIntent/responses/PaymentIntentCreateResponse.java b/src/main/java/com/chargebee/v4/models/paymentIntent/responses/PaymentIntentCreateResponse.java index b1870f2f..ad7b566d 100644 --- a/src/main/java/com/chargebee/v4/models/paymentIntent/responses/PaymentIntentCreateResponse.java +++ b/src/main/java/com/chargebee/v4/models/paymentIntent/responses/PaymentIntentCreateResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static PaymentIntentCreateResponse fromJson(String json) { /** Parse JSON response into PaymentIntentCreateResponse object with HTTP response. */ public static PaymentIntentCreateResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __paymentIntentJson = JsonUtil.getObject(json, "payment_intent"); - if (__paymentIntentJson != null) { - builder.paymentIntent(PaymentIntent.fromJson(__paymentIntentJson)); + JsonObject __paymentIntentObj = JsonUtil.getJsonObject(jsonObj, "payment_intent"); + if (__paymentIntentObj != null) { + builder.paymentIntent(PaymentIntent.fromJson(__paymentIntentObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/paymentIntent/responses/PaymentIntentRetrieveResponse.java b/src/main/java/com/chargebee/v4/models/paymentIntent/responses/PaymentIntentRetrieveResponse.java index 90ecccd1..505e2212 100644 --- a/src/main/java/com/chargebee/v4/models/paymentIntent/responses/PaymentIntentRetrieveResponse.java +++ b/src/main/java/com/chargebee/v4/models/paymentIntent/responses/PaymentIntentRetrieveResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static PaymentIntentRetrieveResponse fromJson(String json) { /** Parse JSON response into PaymentIntentRetrieveResponse object with HTTP response. */ public static PaymentIntentRetrieveResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __paymentIntentJson = JsonUtil.getObject(json, "payment_intent"); - if (__paymentIntentJson != null) { - builder.paymentIntent(PaymentIntent.fromJson(__paymentIntentJson)); + JsonObject __paymentIntentObj = JsonUtil.getJsonObject(jsonObj, "payment_intent"); + if (__paymentIntentObj != null) { + builder.paymentIntent(PaymentIntent.fromJson(__paymentIntentObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/paymentIntent/responses/PaymentIntentUpdateResponse.java b/src/main/java/com/chargebee/v4/models/paymentIntent/responses/PaymentIntentUpdateResponse.java index 1e074240..225aea16 100644 --- a/src/main/java/com/chargebee/v4/models/paymentIntent/responses/PaymentIntentUpdateResponse.java +++ b/src/main/java/com/chargebee/v4/models/paymentIntent/responses/PaymentIntentUpdateResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static PaymentIntentUpdateResponse fromJson(String json) { /** Parse JSON response into PaymentIntentUpdateResponse object with HTTP response. */ public static PaymentIntentUpdateResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __paymentIntentJson = JsonUtil.getObject(json, "payment_intent"); - if (__paymentIntentJson != null) { - builder.paymentIntent(PaymentIntent.fromJson(__paymentIntentJson)); + JsonObject __paymentIntentObj = JsonUtil.getJsonObject(jsonObj, "payment_intent"); + if (__paymentIntentObj != null) { + builder.paymentIntent(PaymentIntent.fromJson(__paymentIntentObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/paymentReferenceNumber/PaymentReferenceNumber.java b/src/main/java/com/chargebee/v4/models/paymentReferenceNumber/PaymentReferenceNumber.java index 7c7947e6..23756e02 100644 --- a/src/main/java/com/chargebee/v4/models/paymentReferenceNumber/PaymentReferenceNumber.java +++ b/src/main/java/com/chargebee/v4/models/paymentReferenceNumber/PaymentReferenceNumber.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.paymentReferenceNumber; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; public class PaymentReferenceNumber { @@ -67,15 +68,19 @@ public static Type fromString(String value) { } public static PaymentReferenceNumber fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static PaymentReferenceNumber fromJson(JsonObject jsonObj) { PaymentReferenceNumber obj = new PaymentReferenceNumber(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.type = Type.fromString(JsonUtil.getString(json, "type")); + obj.type = Type.fromString(JsonUtil.getString(jsonObj, "type")); - obj.number = JsonUtil.getString(json, "number"); + obj.number = JsonUtil.getString(jsonObj, "number"); - obj.invoiceId = JsonUtil.getString(json, "invoice_id"); + obj.invoiceId = JsonUtil.getString(jsonObj, "invoice_id"); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/paymentSchedule/PaymentSchedule.java b/src/main/java/com/chargebee/v4/models/paymentSchedule/PaymentSchedule.java index 93299e2e..c79cffb3 100644 --- a/src/main/java/com/chargebee/v4/models/paymentSchedule/PaymentSchedule.java +++ b/src/main/java/com/chargebee/v4/models/paymentSchedule/PaymentSchedule.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.paymentSchedule; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import java.sql.Timestamp; import java.util.List; @@ -91,30 +92,33 @@ public static EntityType fromString(String value) { } public static PaymentSchedule fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static PaymentSchedule fromJson(JsonObject jsonObj) { PaymentSchedule obj = new PaymentSchedule(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.schemeId = JsonUtil.getString(json, "scheme_id"); + obj.schemeId = JsonUtil.getString(jsonObj, "scheme_id"); - obj.entityType = EntityType.fromString(JsonUtil.getString(json, "entity_type")); + obj.entityType = EntityType.fromString(JsonUtil.getString(jsonObj, "entity_type")); - obj.entityId = JsonUtil.getString(json, "entity_id"); + obj.entityId = JsonUtil.getString(jsonObj, "entity_id"); - obj.amount = JsonUtil.getLong(json, "amount"); + obj.amount = JsonUtil.getLong(jsonObj, "amount"); - obj.createdAt = JsonUtil.getTimestamp(json, "created_at"); + obj.createdAt = JsonUtil.getTimestamp(jsonObj, "created_at"); - obj.resourceVersion = JsonUtil.getLong(json, "resource_version"); + obj.resourceVersion = JsonUtil.getLong(jsonObj, "resource_version"); - obj.updatedAt = JsonUtil.getTimestamp(json, "updated_at"); + obj.updatedAt = JsonUtil.getTimestamp(jsonObj, "updated_at"); - obj.currencyCode = JsonUtil.getString(json, "currency_code"); + obj.currencyCode = JsonUtil.getString(jsonObj, "currency_code"); obj.scheduleEntries = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "schedule_entries")).stream() - .map(ScheduleEntries::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "schedule_entries"), ScheduleEntries::fromJson); return obj; } @@ -233,15 +237,19 @@ public static Status fromString(String value) { } public static ScheduleEntries fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static ScheduleEntries fromJson(JsonObject jsonObj) { ScheduleEntries obj = new ScheduleEntries(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.date = JsonUtil.getTimestamp(json, "date"); + obj.date = JsonUtil.getTimestamp(jsonObj, "date"); - obj.amount = JsonUtil.getLong(json, "amount"); + obj.amount = JsonUtil.getLong(jsonObj, "amount"); - obj.status = Status.fromString(JsonUtil.getString(json, "status")); + obj.status = Status.fromString(JsonUtil.getString(jsonObj, "status")); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/paymentScheduleEstimate/PaymentScheduleEstimate.java b/src/main/java/com/chargebee/v4/models/paymentScheduleEstimate/PaymentScheduleEstimate.java index 41259968..9d0ee784 100644 --- a/src/main/java/com/chargebee/v4/models/paymentScheduleEstimate/PaymentScheduleEstimate.java +++ b/src/main/java/com/chargebee/v4/models/paymentScheduleEstimate/PaymentScheduleEstimate.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.paymentScheduleEstimate; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import java.sql.Timestamp; import java.util.List; @@ -76,24 +77,27 @@ public static EntityType fromString(String value) { } public static PaymentScheduleEstimate fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static PaymentScheduleEstimate fromJson(JsonObject jsonObj) { PaymentScheduleEstimate obj = new PaymentScheduleEstimate(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.schemeId = JsonUtil.getString(json, "scheme_id"); + obj.schemeId = JsonUtil.getString(jsonObj, "scheme_id"); - obj.entityType = EntityType.fromString(JsonUtil.getString(json, "entity_type")); + obj.entityType = EntityType.fromString(JsonUtil.getString(jsonObj, "entity_type")); - obj.entityId = JsonUtil.getString(json, "entity_id"); + obj.entityId = JsonUtil.getString(jsonObj, "entity_id"); - obj.amount = JsonUtil.getLong(json, "amount"); + obj.amount = JsonUtil.getLong(jsonObj, "amount"); - obj.currencyCode = JsonUtil.getString(json, "currency_code"); + obj.currencyCode = JsonUtil.getString(jsonObj, "currency_code"); obj.scheduleEntries = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "schedule_entries")).stream() - .map(ScheduleEntries::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "schedule_entries"), ScheduleEntries::fromJson); return obj; } @@ -194,15 +198,19 @@ public static Status fromString(String value) { } public static ScheduleEntries fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static ScheduleEntries fromJson(JsonObject jsonObj) { ScheduleEntries obj = new ScheduleEntries(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.date = JsonUtil.getTimestamp(json, "date"); + obj.date = JsonUtil.getTimestamp(jsonObj, "date"); - obj.amount = JsonUtil.getLong(json, "amount"); + obj.amount = JsonUtil.getLong(jsonObj, "amount"); - obj.status = Status.fromString(JsonUtil.getString(json, "status")); + obj.status = Status.fromString(JsonUtil.getString(jsonObj, "status")); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/paymentScheduleScheme/PaymentScheduleScheme.java b/src/main/java/com/chargebee/v4/models/paymentScheduleScheme/PaymentScheduleScheme.java index a5756b0e..4abb118d 100644 --- a/src/main/java/com/chargebee/v4/models/paymentScheduleScheme/PaymentScheduleScheme.java +++ b/src/main/java/com/chargebee/v4/models/paymentScheduleScheme/PaymentScheduleScheme.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.paymentScheduleScheme; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import java.math.BigDecimal; import java.sql.Timestamp; import java.util.List; @@ -97,30 +98,33 @@ public static PeriodUnit fromString(String value) { } public static PaymentScheduleScheme fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static PaymentScheduleScheme fromJson(JsonObject jsonObj) { PaymentScheduleScheme obj = new PaymentScheduleScheme(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.name = JsonUtil.getString(json, "name"); + obj.name = JsonUtil.getString(jsonObj, "name"); - obj.description = JsonUtil.getString(json, "description"); + obj.description = JsonUtil.getString(jsonObj, "description"); - obj.numberOfSchedules = JsonUtil.getInteger(json, "number_of_schedules"); + obj.numberOfSchedules = JsonUtil.getInteger(jsonObj, "number_of_schedules"); - obj.periodUnit = PeriodUnit.fromString(JsonUtil.getString(json, "period_unit")); + obj.periodUnit = PeriodUnit.fromString(JsonUtil.getString(jsonObj, "period_unit")); - obj.period = JsonUtil.getInteger(json, "period"); + obj.period = JsonUtil.getInteger(jsonObj, "period"); - obj.createdAt = JsonUtil.getTimestamp(json, "created_at"); + obj.createdAt = JsonUtil.getTimestamp(jsonObj, "created_at"); - obj.resourceVersion = JsonUtil.getLong(json, "resource_version"); + obj.resourceVersion = JsonUtil.getLong(jsonObj, "resource_version"); - obj.updatedAt = JsonUtil.getTimestamp(json, "updated_at"); + obj.updatedAt = JsonUtil.getTimestamp(jsonObj, "updated_at"); obj.preferredSchedules = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "preferred_schedules")).stream() - .map(PreferredSchedules::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "preferred_schedules"), PreferredSchedules::fromJson); return obj; } @@ -199,11 +203,15 @@ public BigDecimal getAmountPercentage() { } public static PreferredSchedules fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static PreferredSchedules fromJson(JsonObject jsonObj) { PreferredSchedules obj = new PreferredSchedules(); - obj.period = JsonUtil.getInteger(json, "period"); + obj.period = JsonUtil.getInteger(jsonObj, "period"); - obj.amountPercentage = JsonUtil.getBigDecimal(json, "amount_percentage"); + obj.amountPercentage = JsonUtil.getBigDecimal(jsonObj, "amount_percentage"); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/paymentScheduleScheme/responses/PaymentScheduleSchemeCreateResponse.java b/src/main/java/com/chargebee/v4/models/paymentScheduleScheme/responses/PaymentScheduleSchemeCreateResponse.java index 78b47a24..1c70de0f 100644 --- a/src/main/java/com/chargebee/v4/models/paymentScheduleScheme/responses/PaymentScheduleSchemeCreateResponse.java +++ b/src/main/java/com/chargebee/v4/models/paymentScheduleScheme/responses/PaymentScheduleSchemeCreateResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,13 @@ public static PaymentScheduleSchemeCreateResponse fromJson(String json) { /** Parse JSON response into PaymentScheduleSchemeCreateResponse object with HTTP response. */ public static PaymentScheduleSchemeCreateResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __paymentScheduleSchemeJson = JsonUtil.getObject(json, "payment_schedule_scheme"); - if (__paymentScheduleSchemeJson != null) { - builder.paymentScheduleScheme(PaymentScheduleScheme.fromJson(__paymentScheduleSchemeJson)); + JsonObject __paymentScheduleSchemeObj = + JsonUtil.getJsonObject(jsonObj, "payment_schedule_scheme"); + if (__paymentScheduleSchemeObj != null) { + builder.paymentScheduleScheme(PaymentScheduleScheme.fromJson(__paymentScheduleSchemeObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/paymentScheduleScheme/responses/PaymentScheduleSchemeDeleteResponse.java b/src/main/java/com/chargebee/v4/models/paymentScheduleScheme/responses/PaymentScheduleSchemeDeleteResponse.java index 6a2d4b56..378965e6 100644 --- a/src/main/java/com/chargebee/v4/models/paymentScheduleScheme/responses/PaymentScheduleSchemeDeleteResponse.java +++ b/src/main/java/com/chargebee/v4/models/paymentScheduleScheme/responses/PaymentScheduleSchemeDeleteResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,13 @@ public static PaymentScheduleSchemeDeleteResponse fromJson(String json) { /** Parse JSON response into PaymentScheduleSchemeDeleteResponse object with HTTP response. */ public static PaymentScheduleSchemeDeleteResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __paymentScheduleSchemeJson = JsonUtil.getObject(json, "payment_schedule_scheme"); - if (__paymentScheduleSchemeJson != null) { - builder.paymentScheduleScheme(PaymentScheduleScheme.fromJson(__paymentScheduleSchemeJson)); + JsonObject __paymentScheduleSchemeObj = + JsonUtil.getJsonObject(jsonObj, "payment_schedule_scheme"); + if (__paymentScheduleSchemeObj != null) { + builder.paymentScheduleScheme(PaymentScheduleScheme.fromJson(__paymentScheduleSchemeObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/paymentScheduleScheme/responses/PaymentScheduleSchemeRetrieveResponse.java b/src/main/java/com/chargebee/v4/models/paymentScheduleScheme/responses/PaymentScheduleSchemeRetrieveResponse.java index 2f8ad7ae..11c951f4 100644 --- a/src/main/java/com/chargebee/v4/models/paymentScheduleScheme/responses/PaymentScheduleSchemeRetrieveResponse.java +++ b/src/main/java/com/chargebee/v4/models/paymentScheduleScheme/responses/PaymentScheduleSchemeRetrieveResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,13 @@ public static PaymentScheduleSchemeRetrieveResponse fromJson(String json) { /** Parse JSON response into PaymentScheduleSchemeRetrieveResponse object with HTTP response. */ public static PaymentScheduleSchemeRetrieveResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __paymentScheduleSchemeJson = JsonUtil.getObject(json, "payment_schedule_scheme"); - if (__paymentScheduleSchemeJson != null) { - builder.paymentScheduleScheme(PaymentScheduleScheme.fromJson(__paymentScheduleSchemeJson)); + JsonObject __paymentScheduleSchemeObj = + JsonUtil.getJsonObject(jsonObj, "payment_schedule_scheme"); + if (__paymentScheduleSchemeObj != null) { + builder.paymentScheduleScheme(PaymentScheduleScheme.fromJson(__paymentScheduleSchemeObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/paymentSource/PaymentSource.java b/src/main/java/com/chargebee/v4/models/paymentSource/PaymentSource.java index 4d7a6404..fbbf7a7b 100644 --- a/src/main/java/com/chargebee/v4/models/paymentSource/PaymentSource.java +++ b/src/main/java/com/chargebee/v4/models/paymentSource/PaymentSource.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.paymentSource; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import java.sql.Timestamp; import java.util.List; @@ -403,85 +404,87 @@ public static Gateway fromString(String value) { } public static PaymentSource fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static PaymentSource fromJson(JsonObject jsonObj) { PaymentSource obj = new PaymentSource(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.resourceVersion = JsonUtil.getLong(json, "resource_version"); + obj.resourceVersion = JsonUtil.getLong(jsonObj, "resource_version"); - obj.updatedAt = JsonUtil.getTimestamp(json, "updated_at"); + obj.updatedAt = JsonUtil.getTimestamp(jsonObj, "updated_at"); - obj.createdAt = JsonUtil.getTimestamp(json, "created_at"); + obj.createdAt = JsonUtil.getTimestamp(jsonObj, "created_at"); - obj.customerId = JsonUtil.getString(json, "customer_id"); + obj.customerId = JsonUtil.getString(jsonObj, "customer_id"); - obj.type = Type.fromString(JsonUtil.getString(json, "type")); + obj.type = Type.fromString(JsonUtil.getString(jsonObj, "type")); - obj.referenceId = JsonUtil.getString(json, "reference_id"); + obj.referenceId = JsonUtil.getString(jsonObj, "reference_id"); - obj.status = Status.fromString(JsonUtil.getString(json, "status")); + obj.status = Status.fromString(JsonUtil.getString(jsonObj, "status")); - obj.gateway = Gateway.fromString(JsonUtil.getString(json, "gateway")); + obj.gateway = Gateway.fromString(JsonUtil.getString(jsonObj, "gateway")); - obj.gatewayAccountId = JsonUtil.getString(json, "gateway_account_id"); + obj.gatewayAccountId = JsonUtil.getString(jsonObj, "gateway_account_id"); - obj.ipAddress = JsonUtil.getString(json, "ip_address"); + obj.ipAddress = JsonUtil.getString(jsonObj, "ip_address"); - obj.issuingCountry = JsonUtil.getString(json, "issuing_country"); + obj.issuingCountry = JsonUtil.getString(jsonObj, "issuing_country"); - obj.deleted = JsonUtil.getBoolean(json, "deleted"); + obj.deleted = JsonUtil.getBoolean(jsonObj, "deleted"); - obj.businessEntityId = JsonUtil.getString(json, "business_entity_id"); + obj.businessEntityId = JsonUtil.getString(jsonObj, "business_entity_id"); - String __cardJson = JsonUtil.getObject(json, "card"); - if (__cardJson != null) { - obj.card = Card.fromJson(__cardJson); + JsonObject __cardObj = JsonUtil.getJsonObject(jsonObj, "card"); + if (__cardObj != null) { + obj.card = Card.fromJson(__cardObj); } - String __bankAccountJson = JsonUtil.getObject(json, "bank_account"); - if (__bankAccountJson != null) { - obj.bankAccount = BankAccount.fromJson(__bankAccountJson); + JsonObject __bankAccountObj = JsonUtil.getJsonObject(jsonObj, "bank_account"); + if (__bankAccountObj != null) { + obj.bankAccount = BankAccount.fromJson(__bankAccountObj); } - String __boletoJson = JsonUtil.getObject(json, "boleto"); - if (__boletoJson != null) { - obj.boleto = Boleto.fromJson(__boletoJson); + JsonObject __boletoObj = JsonUtil.getJsonObject(jsonObj, "boleto"); + if (__boletoObj != null) { + obj.boleto = Boleto.fromJson(__boletoObj); } - String __billingAddressJson = JsonUtil.getObject(json, "billing_address"); - if (__billingAddressJson != null) { - obj.billingAddress = BillingAddress.fromJson(__billingAddressJson); + JsonObject __billingAddressObj = JsonUtil.getJsonObject(jsonObj, "billing_address"); + if (__billingAddressObj != null) { + obj.billingAddress = BillingAddress.fromJson(__billingAddressObj); } - String __amazonPaymentJson = JsonUtil.getObject(json, "amazon_payment"); - if (__amazonPaymentJson != null) { - obj.amazonPayment = AmazonPayment.fromJson(__amazonPaymentJson); + JsonObject __amazonPaymentObj = JsonUtil.getJsonObject(jsonObj, "amazon_payment"); + if (__amazonPaymentObj != null) { + obj.amazonPayment = AmazonPayment.fromJson(__amazonPaymentObj); } - String __upiJson = JsonUtil.getObject(json, "upi"); - if (__upiJson != null) { - obj.upi = Upi.fromJson(__upiJson); + JsonObject __upiObj = JsonUtil.getJsonObject(jsonObj, "upi"); + if (__upiObj != null) { + obj.upi = Upi.fromJson(__upiObj); } - String __paypalJson = JsonUtil.getObject(json, "paypal"); - if (__paypalJson != null) { - obj.paypal = Paypal.fromJson(__paypalJson); + JsonObject __paypalObj = JsonUtil.getJsonObject(jsonObj, "paypal"); + if (__paypalObj != null) { + obj.paypal = Paypal.fromJson(__paypalObj); } - String __venmoJson = JsonUtil.getObject(json, "venmo"); - if (__venmoJson != null) { - obj.venmo = Venmo.fromJson(__venmoJson); + JsonObject __venmoObj = JsonUtil.getJsonObject(jsonObj, "venmo"); + if (__venmoObj != null) { + obj.venmo = Venmo.fromJson(__venmoObj); } - String __klarnaPayNowJson = JsonUtil.getObject(json, "klarna_pay_now"); - if (__klarnaPayNowJson != null) { - obj.klarnaPayNow = KlarnaPayNow.fromJson(__klarnaPayNowJson); + JsonObject __klarnaPayNowObj = JsonUtil.getJsonObject(jsonObj, "klarna_pay_now"); + if (__klarnaPayNowObj != null) { + obj.klarnaPayNow = KlarnaPayNow.fromJson(__klarnaPayNowObj); } obj.mandates = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "mandates")).stream() - .map(Mandates::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "mandates"), Mandates::fromJson); return obj; } @@ -788,39 +791,43 @@ public static FundingType fromString(String value) { } public static Card fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Card fromJson(JsonObject jsonObj) { Card obj = new Card(); - obj.firstName = JsonUtil.getString(json, "first_name"); + obj.firstName = JsonUtil.getString(jsonObj, "first_name"); - obj.lastName = JsonUtil.getString(json, "last_name"); + obj.lastName = JsonUtil.getString(jsonObj, "last_name"); - obj.iin = JsonUtil.getString(json, "iin"); + obj.iin = JsonUtil.getString(jsonObj, "iin"); - obj.last4 = JsonUtil.getString(json, "last4"); + obj.last4 = JsonUtil.getString(jsonObj, "last4"); - obj.brand = Brand.fromString(JsonUtil.getString(json, "brand")); + obj.brand = Brand.fromString(JsonUtil.getString(jsonObj, "brand")); - obj.fundingType = FundingType.fromString(JsonUtil.getString(json, "funding_type")); + obj.fundingType = FundingType.fromString(JsonUtil.getString(jsonObj, "funding_type")); - obj.expiryMonth = JsonUtil.getInteger(json, "expiry_month"); + obj.expiryMonth = JsonUtil.getInteger(jsonObj, "expiry_month"); - obj.expiryYear = JsonUtil.getInteger(json, "expiry_year"); + obj.expiryYear = JsonUtil.getInteger(jsonObj, "expiry_year"); - obj.billingAddr1 = JsonUtil.getString(json, "billing_addr1"); + obj.billingAddr1 = JsonUtil.getString(jsonObj, "billing_addr1"); - obj.billingAddr2 = JsonUtil.getString(json, "billing_addr2"); + obj.billingAddr2 = JsonUtil.getString(jsonObj, "billing_addr2"); - obj.billingCity = JsonUtil.getString(json, "billing_city"); + obj.billingCity = JsonUtil.getString(jsonObj, "billing_city"); - obj.billingStateCode = JsonUtil.getString(json, "billing_state_code"); + obj.billingStateCode = JsonUtil.getString(jsonObj, "billing_state_code"); - obj.billingState = JsonUtil.getString(json, "billing_state"); + obj.billingState = JsonUtil.getString(jsonObj, "billing_state"); - obj.billingCountry = JsonUtil.getString(json, "billing_country"); + obj.billingCountry = JsonUtil.getString(jsonObj, "billing_country"); - obj.billingZip = JsonUtil.getString(json, "billing_zip"); + obj.billingZip = JsonUtil.getString(jsonObj, "billing_zip"); - obj.maskedNumber = JsonUtil.getString(json, "masked_number"); + obj.maskedNumber = JsonUtil.getString(jsonObj, "masked_number"); return obj; } @@ -1103,31 +1110,35 @@ public static AccountHolderType fromString(String value) { } public static BankAccount fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static BankAccount fromJson(JsonObject jsonObj) { BankAccount obj = new BankAccount(); - obj.last4 = JsonUtil.getString(json, "last4"); + obj.last4 = JsonUtil.getString(jsonObj, "last4"); - obj.nameOnAccount = JsonUtil.getString(json, "name_on_account"); + obj.nameOnAccount = JsonUtil.getString(jsonObj, "name_on_account"); - obj.firstName = JsonUtil.getString(json, "first_name"); + obj.firstName = JsonUtil.getString(jsonObj, "first_name"); - obj.lastName = JsonUtil.getString(json, "last_name"); + obj.lastName = JsonUtil.getString(jsonObj, "last_name"); obj.directDebitScheme = - DirectDebitScheme.fromString(JsonUtil.getString(json, "direct_debit_scheme")); + DirectDebitScheme.fromString(JsonUtil.getString(jsonObj, "direct_debit_scheme")); - obj.bankName = JsonUtil.getString(json, "bank_name"); + obj.bankName = JsonUtil.getString(jsonObj, "bank_name"); - obj.mandateId = JsonUtil.getString(json, "mandate_id"); + obj.mandateId = JsonUtil.getString(jsonObj, "mandate_id"); - obj.accountType = AccountType.fromString(JsonUtil.getString(json, "account_type")); + obj.accountType = AccountType.fromString(JsonUtil.getString(jsonObj, "account_type")); - obj.echeckType = EcheckType.fromString(JsonUtil.getString(json, "echeck_type")); + obj.echeckType = EcheckType.fromString(JsonUtil.getString(jsonObj, "echeck_type")); obj.accountHolderType = - AccountHolderType.fromString(JsonUtil.getString(json, "account_holder_type")); + AccountHolderType.fromString(JsonUtil.getString(jsonObj, "account_holder_type")); - obj.email = JsonUtil.getString(json, "email"); + obj.email = JsonUtil.getString(jsonObj, "email"); return obj; } @@ -1221,15 +1232,19 @@ public String getEmail() { } public static Boleto fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Boleto fromJson(JsonObject jsonObj) { Boleto obj = new Boleto(); - obj.last4 = JsonUtil.getString(json, "last4"); + obj.last4 = JsonUtil.getString(jsonObj, "last4"); - obj.firstName = JsonUtil.getString(json, "first_name"); + obj.firstName = JsonUtil.getString(jsonObj, "first_name"); - obj.lastName = JsonUtil.getString(json, "last_name"); + obj.lastName = JsonUtil.getString(jsonObj, "last_name"); - obj.email = JsonUtil.getString(json, "email"); + obj.email = JsonUtil.getString(jsonObj, "email"); return obj; } @@ -1373,36 +1388,40 @@ public static ValidationStatus fromString(String value) { } public static BillingAddress fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static BillingAddress fromJson(JsonObject jsonObj) { BillingAddress obj = new BillingAddress(); - obj.firstName = JsonUtil.getString(json, "first_name"); + obj.firstName = JsonUtil.getString(jsonObj, "first_name"); - obj.lastName = JsonUtil.getString(json, "last_name"); + obj.lastName = JsonUtil.getString(jsonObj, "last_name"); - obj.email = JsonUtil.getString(json, "email"); + obj.email = JsonUtil.getString(jsonObj, "email"); - obj.company = JsonUtil.getString(json, "company"); + obj.company = JsonUtil.getString(jsonObj, "company"); - obj.phone = JsonUtil.getString(json, "phone"); + obj.phone = JsonUtil.getString(jsonObj, "phone"); - obj.line1 = JsonUtil.getString(json, "line1"); + obj.line1 = JsonUtil.getString(jsonObj, "line1"); - obj.line2 = JsonUtil.getString(json, "line2"); + obj.line2 = JsonUtil.getString(jsonObj, "line2"); - obj.line3 = JsonUtil.getString(json, "line3"); + obj.line3 = JsonUtil.getString(jsonObj, "line3"); - obj.city = JsonUtil.getString(json, "city"); + obj.city = JsonUtil.getString(jsonObj, "city"); - obj.stateCode = JsonUtil.getString(json, "state_code"); + obj.stateCode = JsonUtil.getString(jsonObj, "state_code"); - obj.state = JsonUtil.getString(json, "state"); + obj.state = JsonUtil.getString(jsonObj, "state"); - obj.country = JsonUtil.getString(json, "country"); + obj.country = JsonUtil.getString(jsonObj, "country"); - obj.zip = JsonUtil.getString(json, "zip"); + obj.zip = JsonUtil.getString(jsonObj, "zip"); obj.validationStatus = - ValidationStatus.fromString(JsonUtil.getString(json, "validation_status")); + ValidationStatus.fromString(JsonUtil.getString(jsonObj, "validation_status")); return obj; } @@ -1498,11 +1517,15 @@ public String getAgreementId() { } public static AmazonPayment fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static AmazonPayment fromJson(JsonObject jsonObj) { AmazonPayment obj = new AmazonPayment(); - obj.email = JsonUtil.getString(json, "email"); + obj.email = JsonUtil.getString(jsonObj, "email"); - obj.agreementId = JsonUtil.getString(json, "agreement_id"); + obj.agreementId = JsonUtil.getString(jsonObj, "agreement_id"); return obj; } @@ -1538,9 +1561,13 @@ public String getVpa() { } public static Upi fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Upi fromJson(JsonObject jsonObj) { Upi obj = new Upi(); - obj.vpa = JsonUtil.getString(json, "vpa"); + obj.vpa = JsonUtil.getString(jsonObj, "vpa"); return obj; } @@ -1580,11 +1607,15 @@ public String getAgreementId() { } public static Paypal fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Paypal fromJson(JsonObject jsonObj) { Paypal obj = new Paypal(); - obj.email = JsonUtil.getString(json, "email"); + obj.email = JsonUtil.getString(jsonObj, "email"); - obj.agreementId = JsonUtil.getString(json, "agreement_id"); + obj.agreementId = JsonUtil.getString(jsonObj, "agreement_id"); return obj; } @@ -1620,9 +1651,13 @@ public String getUserName() { } public static Venmo fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Venmo fromJson(JsonObject jsonObj) { Venmo obj = new Venmo(); - obj.userName = JsonUtil.getString(json, "user_name"); + obj.userName = JsonUtil.getString(jsonObj, "user_name"); return obj; } @@ -1657,9 +1692,13 @@ public String getEmail() { } public static KlarnaPayNow fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static KlarnaPayNow fromJson(JsonObject jsonObj) { KlarnaPayNow obj = new KlarnaPayNow(); - obj.email = JsonUtil.getString(json, "email"); + obj.email = JsonUtil.getString(jsonObj, "email"); return obj; } @@ -1704,13 +1743,17 @@ public Timestamp getCreatedAt() { } public static Mandates fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Mandates fromJson(JsonObject jsonObj) { Mandates obj = new Mandates(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.subscriptionId = JsonUtil.getString(json, "subscription_id"); + obj.subscriptionId = JsonUtil.getString(jsonObj, "subscription_id"); - obj.createdAt = JsonUtil.getTimestamp(json, "created_at"); + obj.createdAt = JsonUtil.getTimestamp(jsonObj, "created_at"); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/paymentSource/responses/CreateVoucherPaymentSourceResponse.java b/src/main/java/com/chargebee/v4/models/paymentSource/responses/CreateVoucherPaymentSourceResponse.java index 45bfc707..c6755983 100644 --- a/src/main/java/com/chargebee/v4/models/paymentSource/responses/CreateVoucherPaymentSourceResponse.java +++ b/src/main/java/com/chargebee/v4/models/paymentSource/responses/CreateVoucherPaymentSourceResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -33,16 +34,17 @@ public static CreateVoucherPaymentSourceResponse fromJson(String json) { /** Parse JSON response into CreateVoucherPaymentSourceResponse object with HTTP response. */ public static CreateVoucherPaymentSourceResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - builder.customer(Customer.fromJson(__customerJson)); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + builder.customer(Customer.fromJson(__customerObj)); } - String __paymentSourceJson = JsonUtil.getObject(json, "payment_source"); - if (__paymentSourceJson != null) { - builder.paymentSource(PaymentSource.fromJson(__paymentSourceJson)); + JsonObject __paymentSourceObj = JsonUtil.getJsonObject(jsonObj, "payment_source"); + if (__paymentSourceObj != null) { + builder.paymentSource(PaymentSource.fromJson(__paymentSourceObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/paymentSource/responses/ExportPaymentSourceResponse.java b/src/main/java/com/chargebee/v4/models/paymentSource/responses/ExportPaymentSourceResponse.java index 149cdb32..f3993a06 100644 --- a/src/main/java/com/chargebee/v4/models/paymentSource/responses/ExportPaymentSourceResponse.java +++ b/src/main/java/com/chargebee/v4/models/paymentSource/responses/ExportPaymentSourceResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,12 +28,14 @@ public static ExportPaymentSourceResponse fromJson(String json) { /** Parse JSON response into ExportPaymentSourceResponse object with HTTP response. */ public static ExportPaymentSourceResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __thirdPartyPaymentMethodJson = JsonUtil.getObject(json, "third_party_payment_method"); - if (__thirdPartyPaymentMethodJson != null) { + JsonObject __thirdPartyPaymentMethodObj = + JsonUtil.getJsonObject(jsonObj, "third_party_payment_method"); + if (__thirdPartyPaymentMethodObj != null) { builder.thirdPartyPaymentMethod( - ThirdPartyPaymentMethod.fromJson(__thirdPartyPaymentMethodJson)); + ThirdPartyPaymentMethod.fromJson(__thirdPartyPaymentMethodObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/paymentSource/responses/PaymentSourceAgreementPdfResponse.java b/src/main/java/com/chargebee/v4/models/paymentSource/responses/PaymentSourceAgreementPdfResponse.java index 77ab3a68..82f04cea 100644 --- a/src/main/java/com/chargebee/v4/models/paymentSource/responses/PaymentSourceAgreementPdfResponse.java +++ b/src/main/java/com/chargebee/v4/models/paymentSource/responses/PaymentSourceAgreementPdfResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static PaymentSourceAgreementPdfResponse fromJson(String json) { /** Parse JSON response into PaymentSourceAgreementPdfResponse object with HTTP response. */ public static PaymentSourceAgreementPdfResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __downloadJson = JsonUtil.getObject(json, "download"); - if (__downloadJson != null) { - builder.download(Download.fromJson(__downloadJson)); + JsonObject __downloadObj = JsonUtil.getJsonObject(jsonObj, "download"); + if (__downloadObj != null) { + builder.download(Download.fromJson(__downloadObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/paymentSource/responses/PaymentSourceCreateBankAccountResponse.java b/src/main/java/com/chargebee/v4/models/paymentSource/responses/PaymentSourceCreateBankAccountResponse.java index 9fbc124b..2dd9fc79 100644 --- a/src/main/java/com/chargebee/v4/models/paymentSource/responses/PaymentSourceCreateBankAccountResponse.java +++ b/src/main/java/com/chargebee/v4/models/paymentSource/responses/PaymentSourceCreateBankAccountResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -34,16 +35,17 @@ public static PaymentSourceCreateBankAccountResponse fromJson(String json) { public static PaymentSourceCreateBankAccountResponse fromJson( String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - builder.customer(Customer.fromJson(__customerJson)); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + builder.customer(Customer.fromJson(__customerObj)); } - String __paymentSourceJson = JsonUtil.getObject(json, "payment_source"); - if (__paymentSourceJson != null) { - builder.paymentSource(PaymentSource.fromJson(__paymentSourceJson)); + JsonObject __paymentSourceObj = JsonUtil.getJsonObject(jsonObj, "payment_source"); + if (__paymentSourceObj != null) { + builder.paymentSource(PaymentSource.fromJson(__paymentSourceObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/paymentSource/responses/PaymentSourceCreateCardResponse.java b/src/main/java/com/chargebee/v4/models/paymentSource/responses/PaymentSourceCreateCardResponse.java index 8e3b5b2a..096544d3 100644 --- a/src/main/java/com/chargebee/v4/models/paymentSource/responses/PaymentSourceCreateCardResponse.java +++ b/src/main/java/com/chargebee/v4/models/paymentSource/responses/PaymentSourceCreateCardResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -33,16 +34,17 @@ public static PaymentSourceCreateCardResponse fromJson(String json) { /** Parse JSON response into PaymentSourceCreateCardResponse object with HTTP response. */ public static PaymentSourceCreateCardResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - builder.customer(Customer.fromJson(__customerJson)); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + builder.customer(Customer.fromJson(__customerObj)); } - String __paymentSourceJson = JsonUtil.getObject(json, "payment_source"); - if (__paymentSourceJson != null) { - builder.paymentSource(PaymentSource.fromJson(__paymentSourceJson)); + JsonObject __paymentSourceObj = JsonUtil.getJsonObject(jsonObj, "payment_source"); + if (__paymentSourceObj != null) { + builder.paymentSource(PaymentSource.fromJson(__paymentSourceObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/paymentSource/responses/PaymentSourceCreateUsingPaymentIntentResponse.java b/src/main/java/com/chargebee/v4/models/paymentSource/responses/PaymentSourceCreateUsingPaymentIntentResponse.java index c740aa73..2b8009a6 100644 --- a/src/main/java/com/chargebee/v4/models/paymentSource/responses/PaymentSourceCreateUsingPaymentIntentResponse.java +++ b/src/main/java/com/chargebee/v4/models/paymentSource/responses/PaymentSourceCreateUsingPaymentIntentResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -37,16 +38,17 @@ public static PaymentSourceCreateUsingPaymentIntentResponse fromJson(String json public static PaymentSourceCreateUsingPaymentIntentResponse fromJson( String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - builder.customer(Customer.fromJson(__customerJson)); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + builder.customer(Customer.fromJson(__customerObj)); } - String __paymentSourceJson = JsonUtil.getObject(json, "payment_source"); - if (__paymentSourceJson != null) { - builder.paymentSource(PaymentSource.fromJson(__paymentSourceJson)); + JsonObject __paymentSourceObj = JsonUtil.getJsonObject(jsonObj, "payment_source"); + if (__paymentSourceObj != null) { + builder.paymentSource(PaymentSource.fromJson(__paymentSourceObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/paymentSource/responses/PaymentSourceCreateUsingPermanentTokenResponse.java b/src/main/java/com/chargebee/v4/models/paymentSource/responses/PaymentSourceCreateUsingPermanentTokenResponse.java index a784fc62..6f2ec908 100644 --- a/src/main/java/com/chargebee/v4/models/paymentSource/responses/PaymentSourceCreateUsingPermanentTokenResponse.java +++ b/src/main/java/com/chargebee/v4/models/paymentSource/responses/PaymentSourceCreateUsingPermanentTokenResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -37,16 +38,17 @@ public static PaymentSourceCreateUsingPermanentTokenResponse fromJson(String jso public static PaymentSourceCreateUsingPermanentTokenResponse fromJson( String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - builder.customer(Customer.fromJson(__customerJson)); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + builder.customer(Customer.fromJson(__customerObj)); } - String __paymentSourceJson = JsonUtil.getObject(json, "payment_source"); - if (__paymentSourceJson != null) { - builder.paymentSource(PaymentSource.fromJson(__paymentSourceJson)); + JsonObject __paymentSourceObj = JsonUtil.getJsonObject(jsonObj, "payment_source"); + if (__paymentSourceObj != null) { + builder.paymentSource(PaymentSource.fromJson(__paymentSourceObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/paymentSource/responses/PaymentSourceCreateUsingTempTokenResponse.java b/src/main/java/com/chargebee/v4/models/paymentSource/responses/PaymentSourceCreateUsingTempTokenResponse.java index 4f73c481..1aab5b59 100644 --- a/src/main/java/com/chargebee/v4/models/paymentSource/responses/PaymentSourceCreateUsingTempTokenResponse.java +++ b/src/main/java/com/chargebee/v4/models/paymentSource/responses/PaymentSourceCreateUsingTempTokenResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -36,16 +37,17 @@ public static PaymentSourceCreateUsingTempTokenResponse fromJson(String json) { public static PaymentSourceCreateUsingTempTokenResponse fromJson( String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - builder.customer(Customer.fromJson(__customerJson)); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + builder.customer(Customer.fromJson(__customerObj)); } - String __paymentSourceJson = JsonUtil.getObject(json, "payment_source"); - if (__paymentSourceJson != null) { - builder.paymentSource(PaymentSource.fromJson(__paymentSourceJson)); + JsonObject __paymentSourceObj = JsonUtil.getJsonObject(jsonObj, "payment_source"); + if (__paymentSourceObj != null) { + builder.paymentSource(PaymentSource.fromJson(__paymentSourceObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/paymentSource/responses/PaymentSourceCreateUsingTokenResponse.java b/src/main/java/com/chargebee/v4/models/paymentSource/responses/PaymentSourceCreateUsingTokenResponse.java index dd960dc2..453d9f16 100644 --- a/src/main/java/com/chargebee/v4/models/paymentSource/responses/PaymentSourceCreateUsingTokenResponse.java +++ b/src/main/java/com/chargebee/v4/models/paymentSource/responses/PaymentSourceCreateUsingTokenResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -33,16 +34,17 @@ public static PaymentSourceCreateUsingTokenResponse fromJson(String json) { /** Parse JSON response into PaymentSourceCreateUsingTokenResponse object with HTTP response. */ public static PaymentSourceCreateUsingTokenResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - builder.customer(Customer.fromJson(__customerJson)); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + builder.customer(Customer.fromJson(__customerObj)); } - String __paymentSourceJson = JsonUtil.getObject(json, "payment_source"); - if (__paymentSourceJson != null) { - builder.paymentSource(PaymentSource.fromJson(__paymentSourceJson)); + JsonObject __paymentSourceObj = JsonUtil.getJsonObject(jsonObj, "payment_source"); + if (__paymentSourceObj != null) { + builder.paymentSource(PaymentSource.fromJson(__paymentSourceObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/paymentSource/responses/PaymentSourceDeleteLocalResponse.java b/src/main/java/com/chargebee/v4/models/paymentSource/responses/PaymentSourceDeleteLocalResponse.java index 6bc881cd..32111d33 100644 --- a/src/main/java/com/chargebee/v4/models/paymentSource/responses/PaymentSourceDeleteLocalResponse.java +++ b/src/main/java/com/chargebee/v4/models/paymentSource/responses/PaymentSourceDeleteLocalResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -33,16 +34,17 @@ public static PaymentSourceDeleteLocalResponse fromJson(String json) { /** Parse JSON response into PaymentSourceDeleteLocalResponse object with HTTP response. */ public static PaymentSourceDeleteLocalResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - builder.customer(Customer.fromJson(__customerJson)); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + builder.customer(Customer.fromJson(__customerObj)); } - String __paymentSourceJson = JsonUtil.getObject(json, "payment_source"); - if (__paymentSourceJson != null) { - builder.paymentSource(PaymentSource.fromJson(__paymentSourceJson)); + JsonObject __paymentSourceObj = JsonUtil.getJsonObject(jsonObj, "payment_source"); + if (__paymentSourceObj != null) { + builder.paymentSource(PaymentSource.fromJson(__paymentSourceObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/paymentSource/responses/PaymentSourceDeleteResponse.java b/src/main/java/com/chargebee/v4/models/paymentSource/responses/PaymentSourceDeleteResponse.java index f74bb6fe..c7e81bdc 100644 --- a/src/main/java/com/chargebee/v4/models/paymentSource/responses/PaymentSourceDeleteResponse.java +++ b/src/main/java/com/chargebee/v4/models/paymentSource/responses/PaymentSourceDeleteResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -33,16 +34,17 @@ public static PaymentSourceDeleteResponse fromJson(String json) { /** Parse JSON response into PaymentSourceDeleteResponse object with HTTP response. */ public static PaymentSourceDeleteResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - builder.customer(Customer.fromJson(__customerJson)); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + builder.customer(Customer.fromJson(__customerObj)); } - String __paymentSourceJson = JsonUtil.getObject(json, "payment_source"); - if (__paymentSourceJson != null) { - builder.paymentSource(PaymentSource.fromJson(__paymentSourceJson)); + JsonObject __paymentSourceObj = JsonUtil.getJsonObject(jsonObj, "payment_source"); + if (__paymentSourceObj != null) { + builder.paymentSource(PaymentSource.fromJson(__paymentSourceObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/paymentSource/responses/PaymentSourceListResponse.java b/src/main/java/com/chargebee/v4/models/paymentSource/responses/PaymentSourceListResponse.java index 0653f286..86745d67 100644 --- a/src/main/java/com/chargebee/v4/models/paymentSource/responses/PaymentSourceListResponse.java +++ b/src/main/java/com/chargebee/v4/models/paymentSource/responses/PaymentSourceListResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.exceptions.ChargebeeException; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; import com.chargebee.v4.services.PaymentSourceService; import com.chargebee.v4.models.paymentSource.params.PaymentSourceListParams; @@ -43,13 +44,13 @@ private PaymentSourceListResponse( */ public static PaymentSourceListResponse fromJson(String json) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(PaymentSourceListItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "list"), PaymentSourceListItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new PaymentSourceListResponse(list, nextOffset, null, null, null); } catch (Exception e) { @@ -67,13 +68,13 @@ public static PaymentSourceListResponse fromJson( PaymentSourceListParams originalParams, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(PaymentSourceListItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "list"), PaymentSourceListItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new PaymentSourceListResponse(list, nextOffset, service, originalParams, httpResponse); } catch (Exception e) { @@ -173,11 +174,15 @@ public PaymentSource getPaymentSource() { } public static PaymentSourceListItem fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static PaymentSourceListItem fromJson(JsonObject jsonObj) { PaymentSourceListItem item = new PaymentSourceListItem(); - String __paymentSourceJson = JsonUtil.getObject(json, "payment_source"); - if (__paymentSourceJson != null) { - item.paymentSource = PaymentSource.fromJson(__paymentSourceJson); + JsonObject __paymentSourceObj = JsonUtil.getJsonObject(jsonObj, "payment_source"); + if (__paymentSourceObj != null) { + item.paymentSource = PaymentSource.fromJson(__paymentSourceObj); } return item; diff --git a/src/main/java/com/chargebee/v4/models/paymentSource/responses/PaymentSourceRetrieveResponse.java b/src/main/java/com/chargebee/v4/models/paymentSource/responses/PaymentSourceRetrieveResponse.java index 4e919ec3..57097260 100644 --- a/src/main/java/com/chargebee/v4/models/paymentSource/responses/PaymentSourceRetrieveResponse.java +++ b/src/main/java/com/chargebee/v4/models/paymentSource/responses/PaymentSourceRetrieveResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static PaymentSourceRetrieveResponse fromJson(String json) { /** Parse JSON response into PaymentSourceRetrieveResponse object with HTTP response. */ public static PaymentSourceRetrieveResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __paymentSourceJson = JsonUtil.getObject(json, "payment_source"); - if (__paymentSourceJson != null) { - builder.paymentSource(PaymentSource.fromJson(__paymentSourceJson)); + JsonObject __paymentSourceObj = JsonUtil.getJsonObject(jsonObj, "payment_source"); + if (__paymentSourceObj != null) { + builder.paymentSource(PaymentSource.fromJson(__paymentSourceObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/paymentSource/responses/PaymentSourceSwitchGatewayAccountResponse.java b/src/main/java/com/chargebee/v4/models/paymentSource/responses/PaymentSourceSwitchGatewayAccountResponse.java index 735e708c..a171d635 100644 --- a/src/main/java/com/chargebee/v4/models/paymentSource/responses/PaymentSourceSwitchGatewayAccountResponse.java +++ b/src/main/java/com/chargebee/v4/models/paymentSource/responses/PaymentSourceSwitchGatewayAccountResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -36,16 +37,17 @@ public static PaymentSourceSwitchGatewayAccountResponse fromJson(String json) { public static PaymentSourceSwitchGatewayAccountResponse fromJson( String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - builder.customer(Customer.fromJson(__customerJson)); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + builder.customer(Customer.fromJson(__customerObj)); } - String __paymentSourceJson = JsonUtil.getObject(json, "payment_source"); - if (__paymentSourceJson != null) { - builder.paymentSource(PaymentSource.fromJson(__paymentSourceJson)); + JsonObject __paymentSourceObj = JsonUtil.getJsonObject(jsonObj, "payment_source"); + if (__paymentSourceObj != null) { + builder.paymentSource(PaymentSource.fromJson(__paymentSourceObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/paymentSource/responses/PaymentSourceUpdateBankAccountResponse.java b/src/main/java/com/chargebee/v4/models/paymentSource/responses/PaymentSourceUpdateBankAccountResponse.java index ef04c9c8..852faf0a 100644 --- a/src/main/java/com/chargebee/v4/models/paymentSource/responses/PaymentSourceUpdateBankAccountResponse.java +++ b/src/main/java/com/chargebee/v4/models/paymentSource/responses/PaymentSourceUpdateBankAccountResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -34,16 +35,17 @@ public static PaymentSourceUpdateBankAccountResponse fromJson(String json) { public static PaymentSourceUpdateBankAccountResponse fromJson( String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - builder.customer(Customer.fromJson(__customerJson)); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + builder.customer(Customer.fromJson(__customerObj)); } - String __paymentSourceJson = JsonUtil.getObject(json, "payment_source"); - if (__paymentSourceJson != null) { - builder.paymentSource(PaymentSource.fromJson(__paymentSourceJson)); + JsonObject __paymentSourceObj = JsonUtil.getJsonObject(jsonObj, "payment_source"); + if (__paymentSourceObj != null) { + builder.paymentSource(PaymentSource.fromJson(__paymentSourceObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/paymentSource/responses/PaymentSourceUpdateCardResponse.java b/src/main/java/com/chargebee/v4/models/paymentSource/responses/PaymentSourceUpdateCardResponse.java index f276dd9d..6702c88f 100644 --- a/src/main/java/com/chargebee/v4/models/paymentSource/responses/PaymentSourceUpdateCardResponse.java +++ b/src/main/java/com/chargebee/v4/models/paymentSource/responses/PaymentSourceUpdateCardResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -33,16 +34,17 @@ public static PaymentSourceUpdateCardResponse fromJson(String json) { /** Parse JSON response into PaymentSourceUpdateCardResponse object with HTTP response. */ public static PaymentSourceUpdateCardResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - builder.customer(Customer.fromJson(__customerJson)); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + builder.customer(Customer.fromJson(__customerObj)); } - String __paymentSourceJson = JsonUtil.getObject(json, "payment_source"); - if (__paymentSourceJson != null) { - builder.paymentSource(PaymentSource.fromJson(__paymentSourceJson)); + JsonObject __paymentSourceObj = JsonUtil.getJsonObject(jsonObj, "payment_source"); + if (__paymentSourceObj != null) { + builder.paymentSource(PaymentSource.fromJson(__paymentSourceObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/paymentSource/responses/PaymentSourceVerifyBankAccountResponse.java b/src/main/java/com/chargebee/v4/models/paymentSource/responses/PaymentSourceVerifyBankAccountResponse.java index 9c81ba66..97d0edc5 100644 --- a/src/main/java/com/chargebee/v4/models/paymentSource/responses/PaymentSourceVerifyBankAccountResponse.java +++ b/src/main/java/com/chargebee/v4/models/paymentSource/responses/PaymentSourceVerifyBankAccountResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -28,11 +29,12 @@ public static PaymentSourceVerifyBankAccountResponse fromJson(String json) { public static PaymentSourceVerifyBankAccountResponse fromJson( String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __paymentSourceJson = JsonUtil.getObject(json, "payment_source"); - if (__paymentSourceJson != null) { - builder.paymentSource(PaymentSource.fromJson(__paymentSourceJson)); + JsonObject __paymentSourceObj = JsonUtil.getJsonObject(jsonObj, "payment_source"); + if (__paymentSourceObj != null) { + builder.paymentSource(PaymentSource.fromJson(__paymentSourceObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/paymentVoucher/PaymentVoucher.java b/src/main/java/com/chargebee/v4/models/paymentVoucher/PaymentVoucher.java index a825cb53..9690451f 100644 --- a/src/main/java/com/chargebee/v4/models/paymentVoucher/PaymentVoucher.java +++ b/src/main/java/com/chargebee/v4/models/paymentVoucher/PaymentVoucher.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.paymentVoucher; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import java.sql.Timestamp; import java.util.List; @@ -315,51 +316,54 @@ public static Gateway fromString(String value) { } public static PaymentVoucher fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static PaymentVoucher fromJson(JsonObject jsonObj) { PaymentVoucher obj = new PaymentVoucher(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.idAtGateway = JsonUtil.getString(json, "id_at_gateway"); + obj.idAtGateway = JsonUtil.getString(jsonObj, "id_at_gateway"); obj.paymentVoucherType = - PaymentVoucherType.fromString(JsonUtil.getString(json, "payment_voucher_type")); + PaymentVoucherType.fromString(JsonUtil.getString(jsonObj, "payment_voucher_type")); - obj.expiresAt = JsonUtil.getTimestamp(json, "expires_at"); + obj.expiresAt = JsonUtil.getTimestamp(jsonObj, "expires_at"); - obj.status = Status.fromString(JsonUtil.getString(json, "status")); + obj.status = Status.fromString(JsonUtil.getString(jsonObj, "status")); - obj.subscriptionId = JsonUtil.getString(json, "subscription_id"); + obj.subscriptionId = JsonUtil.getString(jsonObj, "subscription_id"); - obj.currencyCode = JsonUtil.getString(json, "currency_code"); + obj.currencyCode = JsonUtil.getString(jsonObj, "currency_code"); - obj.amount = JsonUtil.getLong(json, "amount"); + obj.amount = JsonUtil.getLong(jsonObj, "amount"); - obj.gatewayAccountId = JsonUtil.getString(json, "gateway_account_id"); + obj.gatewayAccountId = JsonUtil.getString(jsonObj, "gateway_account_id"); - obj.paymentSourceId = JsonUtil.getString(json, "payment_source_id"); + obj.paymentSourceId = JsonUtil.getString(jsonObj, "payment_source_id"); - obj.gateway = Gateway.fromString(JsonUtil.getString(json, "gateway")); + obj.gateway = Gateway.fromString(JsonUtil.getString(jsonObj, "gateway")); - obj.payload = JsonUtil.getString(json, "payload"); + obj.payload = JsonUtil.getString(jsonObj, "payload"); - obj.errorCode = JsonUtil.getString(json, "error_code"); + obj.errorCode = JsonUtil.getString(jsonObj, "error_code"); - obj.errorText = JsonUtil.getString(json, "error_text"); + obj.errorText = JsonUtil.getString(jsonObj, "error_text"); - obj.url = JsonUtil.getString(json, "url"); + obj.url = JsonUtil.getString(jsonObj, "url"); - obj.date = JsonUtil.getTimestamp(json, "date"); + obj.date = JsonUtil.getTimestamp(jsonObj, "date"); - obj.resourceVersion = JsonUtil.getLong(json, "resource_version"); + obj.resourceVersion = JsonUtil.getLong(jsonObj, "resource_version"); - obj.updatedAt = JsonUtil.getTimestamp(json, "updated_at"); + obj.updatedAt = JsonUtil.getTimestamp(jsonObj, "updated_at"); - obj.customerId = JsonUtil.getString(json, "customer_id"); + obj.customerId = JsonUtil.getString(jsonObj, "customer_id"); obj.linkedInvoices = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "linked_invoices")).stream() - .map(LinkedInvoices::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "linked_invoices"), LinkedInvoices::fromJson); return obj; } @@ -483,13 +487,17 @@ public Timestamp getAppliedAt() { } public static LinkedInvoices fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static LinkedInvoices fromJson(JsonObject jsonObj) { LinkedInvoices obj = new LinkedInvoices(); - obj.invoiceId = JsonUtil.getString(json, "invoice_id"); + obj.invoiceId = JsonUtil.getString(jsonObj, "invoice_id"); - obj.txnId = JsonUtil.getString(json, "txn_id"); + obj.txnId = JsonUtil.getString(jsonObj, "txn_id"); - obj.appliedAt = JsonUtil.getTimestamp(json, "applied_at"); + obj.appliedAt = JsonUtil.getTimestamp(jsonObj, "applied_at"); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/paymentVoucher/responses/PaymentVoucherCreateResponse.java b/src/main/java/com/chargebee/v4/models/paymentVoucher/responses/PaymentVoucherCreateResponse.java index fc9273d5..21a331b4 100644 --- a/src/main/java/com/chargebee/v4/models/paymentVoucher/responses/PaymentVoucherCreateResponse.java +++ b/src/main/java/com/chargebee/v4/models/paymentVoucher/responses/PaymentVoucherCreateResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static PaymentVoucherCreateResponse fromJson(String json) { /** Parse JSON response into PaymentVoucherCreateResponse object with HTTP response. */ public static PaymentVoucherCreateResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __paymentVoucherJson = JsonUtil.getObject(json, "payment_voucher"); - if (__paymentVoucherJson != null) { - builder.paymentVoucher(PaymentVoucher.fromJson(__paymentVoucherJson)); + JsonObject __paymentVoucherObj = JsonUtil.getJsonObject(jsonObj, "payment_voucher"); + if (__paymentVoucherObj != null) { + builder.paymentVoucher(PaymentVoucher.fromJson(__paymentVoucherObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/paymentVoucher/responses/PaymentVoucherRetrieveResponse.java b/src/main/java/com/chargebee/v4/models/paymentVoucher/responses/PaymentVoucherRetrieveResponse.java index d6cd1a37..6aa8af12 100644 --- a/src/main/java/com/chargebee/v4/models/paymentVoucher/responses/PaymentVoucherRetrieveResponse.java +++ b/src/main/java/com/chargebee/v4/models/paymentVoucher/responses/PaymentVoucherRetrieveResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static PaymentVoucherRetrieveResponse fromJson(String json) { /** Parse JSON response into PaymentVoucherRetrieveResponse object with HTTP response. */ public static PaymentVoucherRetrieveResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __paymentVoucherJson = JsonUtil.getObject(json, "payment_voucher"); - if (__paymentVoucherJson != null) { - builder.paymentVoucher(PaymentVoucher.fromJson(__paymentVoucherJson)); + JsonObject __paymentVoucherObj = JsonUtil.getJsonObject(jsonObj, "payment_voucher"); + if (__paymentVoucherObj != null) { + builder.paymentVoucher(PaymentVoucher.fromJson(__paymentVoucherObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/paymentVoucher/responses/PaymentVouchersForCustomerResponse.java b/src/main/java/com/chargebee/v4/models/paymentVoucher/responses/PaymentVouchersForCustomerResponse.java index 7da70f3b..8ad5ef05 100644 --- a/src/main/java/com/chargebee/v4/models/paymentVoucher/responses/PaymentVouchersForCustomerResponse.java +++ b/src/main/java/com/chargebee/v4/models/paymentVoucher/responses/PaymentVouchersForCustomerResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.exceptions.ChargebeeException; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; import com.chargebee.v4.services.PaymentVoucherService; import com.chargebee.v4.models.paymentVoucher.params.PaymentVouchersForCustomerParams; @@ -50,13 +51,14 @@ private PaymentVouchersForCustomerResponse( */ public static PaymentVouchersForCustomerResponse fromJson(String json) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(PaymentVoucherPaymentVouchersForCustomerItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "list"), + PaymentVoucherPaymentVouchersForCustomerItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new PaymentVouchersForCustomerResponse(list, nextOffset, null, null, null, null); } catch (Exception e) { @@ -75,13 +77,14 @@ public static PaymentVouchersForCustomerResponse fromJson( String customerId, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(PaymentVoucherPaymentVouchersForCustomerItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "list"), + PaymentVoucherPaymentVouchersForCustomerItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new PaymentVouchersForCustomerResponse( list, nextOffset, customerId, service, originalParams, httpResponse); @@ -189,12 +192,16 @@ public PaymentVoucher getPaymentVoucher() { } public static PaymentVoucherPaymentVouchersForCustomerItem fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static PaymentVoucherPaymentVouchersForCustomerItem fromJson(JsonObject jsonObj) { PaymentVoucherPaymentVouchersForCustomerItem item = new PaymentVoucherPaymentVouchersForCustomerItem(); - String __paymentVoucherJson = JsonUtil.getObject(json, "payment_voucher"); - if (__paymentVoucherJson != null) { - item.paymentVoucher = PaymentVoucher.fromJson(__paymentVoucherJson); + JsonObject __paymentVoucherObj = JsonUtil.getJsonObject(jsonObj, "payment_voucher"); + if (__paymentVoucherObj != null) { + item.paymentVoucher = PaymentVoucher.fromJson(__paymentVoucherObj); } return item; diff --git a/src/main/java/com/chargebee/v4/models/paymentVoucher/responses/PaymentVouchersForInvoiceResponse.java b/src/main/java/com/chargebee/v4/models/paymentVoucher/responses/PaymentVouchersForInvoiceResponse.java index ee9e9123..db61d01c 100644 --- a/src/main/java/com/chargebee/v4/models/paymentVoucher/responses/PaymentVouchersForInvoiceResponse.java +++ b/src/main/java/com/chargebee/v4/models/paymentVoucher/responses/PaymentVouchersForInvoiceResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.exceptions.ChargebeeException; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; import com.chargebee.v4.services.PaymentVoucherService; import com.chargebee.v4.models.paymentVoucher.params.PaymentVouchersForInvoiceParams; @@ -50,13 +51,14 @@ private PaymentVouchersForInvoiceResponse( */ public static PaymentVouchersForInvoiceResponse fromJson(String json) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(PaymentVoucherPaymentVouchersForInvoiceItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "list"), + PaymentVoucherPaymentVouchersForInvoiceItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new PaymentVouchersForInvoiceResponse(list, nextOffset, null, null, null, null); } catch (Exception e) { @@ -75,13 +77,14 @@ public static PaymentVouchersForInvoiceResponse fromJson( String invoiceId, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(PaymentVoucherPaymentVouchersForInvoiceItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "list"), + PaymentVoucherPaymentVouchersForInvoiceItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new PaymentVouchersForInvoiceResponse( list, nextOffset, invoiceId, service, originalParams, httpResponse); @@ -189,12 +192,16 @@ public PaymentVoucher getPaymentVoucher() { } public static PaymentVoucherPaymentVouchersForInvoiceItem fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static PaymentVoucherPaymentVouchersForInvoiceItem fromJson(JsonObject jsonObj) { PaymentVoucherPaymentVouchersForInvoiceItem item = new PaymentVoucherPaymentVouchersForInvoiceItem(); - String __paymentVoucherJson = JsonUtil.getObject(json, "payment_voucher"); - if (__paymentVoucherJson != null) { - item.paymentVoucher = PaymentVoucher.fromJson(__paymentVoucherJson); + JsonObject __paymentVoucherObj = JsonUtil.getJsonObject(jsonObj, "payment_voucher"); + if (__paymentVoucherObj != null) { + item.paymentVoucher = PaymentVoucher.fromJson(__paymentVoucherObj); } return item; diff --git a/src/main/java/com/chargebee/v4/models/pc2Migration/responses/Pc2MigrationContactSupportResponse.java b/src/main/java/com/chargebee/v4/models/pc2Migration/responses/Pc2MigrationContactSupportResponse.java index 2eaed644..11d64e27 100644 --- a/src/main/java/com/chargebee/v4/models/pc2Migration/responses/Pc2MigrationContactSupportResponse.java +++ b/src/main/java/com/chargebee/v4/models/pc2Migration/responses/Pc2MigrationContactSupportResponse.java @@ -1,6 +1,8 @@ package com.chargebee.v4.models.pc2Migration.responses; import com.chargebee.v4.models.BaseResponse; +import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -21,6 +23,7 @@ public static Pc2MigrationContactSupportResponse fromJson(String json) { /** Parse JSON response into Pc2MigrationContactSupportResponse object with HTTP response. */ public static Pc2MigrationContactSupportResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/pc2Migration/responses/Pc2MigrationCreateResponse.java b/src/main/java/com/chargebee/v4/models/pc2Migration/responses/Pc2MigrationCreateResponse.java index 6ecab06a..1253171b 100644 --- a/src/main/java/com/chargebee/v4/models/pc2Migration/responses/Pc2MigrationCreateResponse.java +++ b/src/main/java/com/chargebee/v4/models/pc2Migration/responses/Pc2MigrationCreateResponse.java @@ -1,6 +1,8 @@ package com.chargebee.v4.models.pc2Migration.responses; import com.chargebee.v4.models.BaseResponse; +import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -21,6 +23,7 @@ public static Pc2MigrationCreateResponse fromJson(String json) { /** Parse JSON response into Pc2MigrationCreateResponse object with HTTP response. */ public static Pc2MigrationCreateResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/pc2Migration/responses/Pc2MigrationInitiateResponse.java b/src/main/java/com/chargebee/v4/models/pc2Migration/responses/Pc2MigrationInitiateResponse.java index 9e29b09e..8920e8c2 100644 --- a/src/main/java/com/chargebee/v4/models/pc2Migration/responses/Pc2MigrationInitiateResponse.java +++ b/src/main/java/com/chargebee/v4/models/pc2Migration/responses/Pc2MigrationInitiateResponse.java @@ -1,6 +1,8 @@ package com.chargebee.v4.models.pc2Migration.responses; import com.chargebee.v4.models.BaseResponse; +import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -21,6 +23,7 @@ public static Pc2MigrationInitiateResponse fromJson(String json) { /** Parse JSON response into Pc2MigrationInitiateResponse object with HTTP response. */ public static Pc2MigrationInitiateResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/pc2Migration/responses/Pc2MigrationRetrieveResponse.java b/src/main/java/com/chargebee/v4/models/pc2Migration/responses/Pc2MigrationRetrieveResponse.java index 3de8846f..5d949567 100644 --- a/src/main/java/com/chargebee/v4/models/pc2Migration/responses/Pc2MigrationRetrieveResponse.java +++ b/src/main/java/com/chargebee/v4/models/pc2Migration/responses/Pc2MigrationRetrieveResponse.java @@ -2,6 +2,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -25,9 +26,10 @@ public static Pc2MigrationRetrieveResponse fromJson(String json) { /** Parse JSON response into Pc2MigrationRetrieveResponse object with HTTP response. */ public static Pc2MigrationRetrieveResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - builder.pc2Migration(JsonUtil.getObject(json, "pc2_migration")); + builder.pc2Migration(JsonUtil.getObject(jsonObj, "pc2_migration")); builder.httpResponse(httpResponse); return builder.build(); diff --git a/src/main/java/com/chargebee/v4/models/pc2MigrationItem/responses/Pc2MigrationItemCreateResponse.java b/src/main/java/com/chargebee/v4/models/pc2MigrationItem/responses/Pc2MigrationItemCreateResponse.java index 84e608e7..dc339f61 100644 --- a/src/main/java/com/chargebee/v4/models/pc2MigrationItem/responses/Pc2MigrationItemCreateResponse.java +++ b/src/main/java/com/chargebee/v4/models/pc2MigrationItem/responses/Pc2MigrationItemCreateResponse.java @@ -1,6 +1,8 @@ package com.chargebee.v4.models.pc2MigrationItem.responses; import com.chargebee.v4.models.BaseResponse; +import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -21,6 +23,7 @@ public static Pc2MigrationItemCreateResponse fromJson(String json) { /** Parse JSON response into Pc2MigrationItemCreateResponse object with HTTP response. */ public static Pc2MigrationItemCreateResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/pc2MigrationItem/responses/Pc2MigrationItemDeleteResponse.java b/src/main/java/com/chargebee/v4/models/pc2MigrationItem/responses/Pc2MigrationItemDeleteResponse.java index 3b7a5d25..126c3e58 100644 --- a/src/main/java/com/chargebee/v4/models/pc2MigrationItem/responses/Pc2MigrationItemDeleteResponse.java +++ b/src/main/java/com/chargebee/v4/models/pc2MigrationItem/responses/Pc2MigrationItemDeleteResponse.java @@ -2,6 +2,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -25,9 +26,10 @@ public static Pc2MigrationItemDeleteResponse fromJson(String json) { /** Parse JSON response into Pc2MigrationItemDeleteResponse object with HTTP response. */ public static Pc2MigrationItemDeleteResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - builder.isDeleted(JsonUtil.getBoolean(json, "is_deleted")); + builder.isDeleted(JsonUtil.getBoolean(jsonObj, "is_deleted")); builder.httpResponse(httpResponse); return builder.build(); diff --git a/src/main/java/com/chargebee/v4/models/pc2MigrationItem/responses/Pc2MigrationItemListApplicableAddonsResponse.java b/src/main/java/com/chargebee/v4/models/pc2MigrationItem/responses/Pc2MigrationItemListApplicableAddonsResponse.java index b902bb37..940faa8b 100644 --- a/src/main/java/com/chargebee/v4/models/pc2MigrationItem/responses/Pc2MigrationItemListApplicableAddonsResponse.java +++ b/src/main/java/com/chargebee/v4/models/pc2MigrationItem/responses/Pc2MigrationItemListApplicableAddonsResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.exceptions.ChargebeeException; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; import com.chargebee.v4.services.Pc2MigrationItemService; import com.chargebee.v4.models.pc2MigrationItem.params.Pc2MigrationItemListApplicableAddonsParams; @@ -44,13 +45,12 @@ private Pc2MigrationItemListApplicableAddonsResponse( */ public static Pc2MigrationItemListApplicableAddonsResponse fromJson(String json) { try { + JsonObject jsonObj = JsonUtil.parse(json); List> list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(JsonUtil::parseJsonObjectToMap) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArrayToMaps(JsonUtil.getJsonArray(jsonObj, "list")); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new Pc2MigrationItemListApplicableAddonsResponse(list, nextOffset, null, null, null); } catch (Exception e) { @@ -69,13 +69,12 @@ public static Pc2MigrationItemListApplicableAddonsResponse fromJson( Pc2MigrationItemListApplicableAddonsParams originalParams, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); List> list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(JsonUtil::parseJsonObjectToMap) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArrayToMaps(JsonUtil.getJsonArray(jsonObj, "list")); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new Pc2MigrationItemListApplicableAddonsResponse( list, nextOffset, service, originalParams, httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/pc2MigrationItem/responses/Pc2MigrationItemListResponse.java b/src/main/java/com/chargebee/v4/models/pc2MigrationItem/responses/Pc2MigrationItemListResponse.java index 4b1a3092..c720c21a 100644 --- a/src/main/java/com/chargebee/v4/models/pc2MigrationItem/responses/Pc2MigrationItemListResponse.java +++ b/src/main/java/com/chargebee/v4/models/pc2MigrationItem/responses/Pc2MigrationItemListResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.exceptions.ChargebeeException; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; import com.chargebee.v4.services.Pc2MigrationItemService; import com.chargebee.v4.models.pc2MigrationItem.params.Pc2MigrationItemListParams; @@ -41,13 +42,12 @@ private Pc2MigrationItemListResponse( */ public static Pc2MigrationItemListResponse fromJson(String json) { try { + JsonObject jsonObj = JsonUtil.parse(json); List> list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(JsonUtil::parseJsonObjectToMap) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArrayToMaps(JsonUtil.getJsonArray(jsonObj, "list")); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new Pc2MigrationItemListResponse(list, nextOffset, null, null, null); } catch (Exception e) { @@ -65,13 +65,12 @@ public static Pc2MigrationItemListResponse fromJson( Pc2MigrationItemListParams originalParams, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); List> list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(JsonUtil::parseJsonObjectToMap) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArrayToMaps(JsonUtil.getJsonArray(jsonObj, "list")); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new Pc2MigrationItemListResponse( list, nextOffset, service, originalParams, httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/pc2MigrationItem/responses/Pc2MigrationItemRetrieveResponse.java b/src/main/java/com/chargebee/v4/models/pc2MigrationItem/responses/Pc2MigrationItemRetrieveResponse.java index bbe2e670..18e043af 100644 --- a/src/main/java/com/chargebee/v4/models/pc2MigrationItem/responses/Pc2MigrationItemRetrieveResponse.java +++ b/src/main/java/com/chargebee/v4/models/pc2MigrationItem/responses/Pc2MigrationItemRetrieveResponse.java @@ -2,6 +2,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -25,9 +26,10 @@ public static Pc2MigrationItemRetrieveResponse fromJson(String json) { /** Parse JSON response into Pc2MigrationItemRetrieveResponse object with HTTP response. */ public static Pc2MigrationItemRetrieveResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - builder.pc2MigrationItem(JsonUtil.getObject(json, "pc2_migration_item")); + builder.pc2MigrationItem(JsonUtil.getObject(jsonObj, "pc2_migration_item")); builder.httpResponse(httpResponse); return builder.build(); diff --git a/src/main/java/com/chargebee/v4/models/pc2MigrationItem/responses/Pc2MigrationItemUpdateResponse.java b/src/main/java/com/chargebee/v4/models/pc2MigrationItem/responses/Pc2MigrationItemUpdateResponse.java index 15f3336e..227655c0 100644 --- a/src/main/java/com/chargebee/v4/models/pc2MigrationItem/responses/Pc2MigrationItemUpdateResponse.java +++ b/src/main/java/com/chargebee/v4/models/pc2MigrationItem/responses/Pc2MigrationItemUpdateResponse.java @@ -1,6 +1,8 @@ package com.chargebee.v4.models.pc2MigrationItem.responses; import com.chargebee.v4.models.BaseResponse; +import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -21,6 +23,7 @@ public static Pc2MigrationItemUpdateResponse fromJson(String json) { /** Parse JSON response into Pc2MigrationItemUpdateResponse object with HTTP response. */ public static Pc2MigrationItemUpdateResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/pc2MigrationItemFamily/responses/Pc2MigrationItemFamilyCreateResponse.java b/src/main/java/com/chargebee/v4/models/pc2MigrationItemFamily/responses/Pc2MigrationItemFamilyCreateResponse.java index 76864765..38b494e9 100644 --- a/src/main/java/com/chargebee/v4/models/pc2MigrationItemFamily/responses/Pc2MigrationItemFamilyCreateResponse.java +++ b/src/main/java/com/chargebee/v4/models/pc2MigrationItemFamily/responses/Pc2MigrationItemFamilyCreateResponse.java @@ -1,6 +1,8 @@ package com.chargebee.v4.models.pc2MigrationItemFamily.responses; import com.chargebee.v4.models.BaseResponse; +import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -21,6 +23,7 @@ public static Pc2MigrationItemFamilyCreateResponse fromJson(String json) { /** Parse JSON response into Pc2MigrationItemFamilyCreateResponse object with HTTP response. */ public static Pc2MigrationItemFamilyCreateResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/pc2MigrationItemFamily/responses/Pc2MigrationItemFamilyDeleteResponse.java b/src/main/java/com/chargebee/v4/models/pc2MigrationItemFamily/responses/Pc2MigrationItemFamilyDeleteResponse.java index f258eab3..dabec333 100644 --- a/src/main/java/com/chargebee/v4/models/pc2MigrationItemFamily/responses/Pc2MigrationItemFamilyDeleteResponse.java +++ b/src/main/java/com/chargebee/v4/models/pc2MigrationItemFamily/responses/Pc2MigrationItemFamilyDeleteResponse.java @@ -2,6 +2,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -25,9 +26,10 @@ public static Pc2MigrationItemFamilyDeleteResponse fromJson(String json) { /** Parse JSON response into Pc2MigrationItemFamilyDeleteResponse object with HTTP response. */ public static Pc2MigrationItemFamilyDeleteResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - builder.isDeleted(JsonUtil.getBoolean(json, "is_deleted")); + builder.isDeleted(JsonUtil.getBoolean(jsonObj, "is_deleted")); builder.httpResponse(httpResponse); return builder.build(); diff --git a/src/main/java/com/chargebee/v4/models/pc2MigrationItemFamily/responses/Pc2MigrationItemFamilyListResponse.java b/src/main/java/com/chargebee/v4/models/pc2MigrationItemFamily/responses/Pc2MigrationItemFamilyListResponse.java index 148aebce..7e111264 100644 --- a/src/main/java/com/chargebee/v4/models/pc2MigrationItemFamily/responses/Pc2MigrationItemFamilyListResponse.java +++ b/src/main/java/com/chargebee/v4/models/pc2MigrationItemFamily/responses/Pc2MigrationItemFamilyListResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.exceptions.ChargebeeException; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; import com.chargebee.v4.services.Pc2MigrationItemFamilyService; import com.chargebee.v4.models.pc2MigrationItemFamily.params.Pc2MigrationItemFamilyListParams; @@ -43,13 +44,12 @@ private Pc2MigrationItemFamilyListResponse( */ public static Pc2MigrationItemFamilyListResponse fromJson(String json) { try { + JsonObject jsonObj = JsonUtil.parse(json); List> list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(JsonUtil::parseJsonObjectToMap) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArrayToMaps(JsonUtil.getJsonArray(jsonObj, "list")); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new Pc2MigrationItemFamilyListResponse(list, nextOffset, null, null, null); } catch (Exception e) { @@ -67,13 +67,12 @@ public static Pc2MigrationItemFamilyListResponse fromJson( Pc2MigrationItemFamilyListParams originalParams, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); List> list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(JsonUtil::parseJsonObjectToMap) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArrayToMaps(JsonUtil.getJsonArray(jsonObj, "list")); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new Pc2MigrationItemFamilyListResponse( list, nextOffset, service, originalParams, httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/pc2MigrationItemFamily/responses/Pc2MigrationItemFamilyRetrieveResponse.java b/src/main/java/com/chargebee/v4/models/pc2MigrationItemFamily/responses/Pc2MigrationItemFamilyRetrieveResponse.java index 24b46cf4..fa95165e 100644 --- a/src/main/java/com/chargebee/v4/models/pc2MigrationItemFamily/responses/Pc2MigrationItemFamilyRetrieveResponse.java +++ b/src/main/java/com/chargebee/v4/models/pc2MigrationItemFamily/responses/Pc2MigrationItemFamilyRetrieveResponse.java @@ -2,6 +2,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -26,9 +27,10 @@ public static Pc2MigrationItemFamilyRetrieveResponse fromJson(String json) { public static Pc2MigrationItemFamilyRetrieveResponse fromJson( String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - builder.pc2MigrationItemFamily(JsonUtil.getObject(json, "pc2_migration_item_family")); + builder.pc2MigrationItemFamily(JsonUtil.getObject(jsonObj, "pc2_migration_item_family")); builder.httpResponse(httpResponse); return builder.build(); diff --git a/src/main/java/com/chargebee/v4/models/pc2MigrationItemFamily/responses/Pc2MigrationItemFamilyUpdateResponse.java b/src/main/java/com/chargebee/v4/models/pc2MigrationItemFamily/responses/Pc2MigrationItemFamilyUpdateResponse.java index d6b825f0..361ad46e 100644 --- a/src/main/java/com/chargebee/v4/models/pc2MigrationItemFamily/responses/Pc2MigrationItemFamilyUpdateResponse.java +++ b/src/main/java/com/chargebee/v4/models/pc2MigrationItemFamily/responses/Pc2MigrationItemFamilyUpdateResponse.java @@ -1,6 +1,8 @@ package com.chargebee.v4.models.pc2MigrationItemFamily.responses; import com.chargebee.v4.models.BaseResponse; +import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -21,6 +23,7 @@ public static Pc2MigrationItemFamilyUpdateResponse fromJson(String json) { /** Parse JSON response into Pc2MigrationItemFamilyUpdateResponse object with HTTP response. */ public static Pc2MigrationItemFamilyUpdateResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/pc2MigrationItemPrice/responses/Pc2MigrationItemPriceDeleteResponse.java b/src/main/java/com/chargebee/v4/models/pc2MigrationItemPrice/responses/Pc2MigrationItemPriceDeleteResponse.java index b2a52ea2..8a437e99 100644 --- a/src/main/java/com/chargebee/v4/models/pc2MigrationItemPrice/responses/Pc2MigrationItemPriceDeleteResponse.java +++ b/src/main/java/com/chargebee/v4/models/pc2MigrationItemPrice/responses/Pc2MigrationItemPriceDeleteResponse.java @@ -2,6 +2,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -25,9 +26,10 @@ public static Pc2MigrationItemPriceDeleteResponse fromJson(String json) { /** Parse JSON response into Pc2MigrationItemPriceDeleteResponse object with HTTP response. */ public static Pc2MigrationItemPriceDeleteResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - builder.isDeleted(JsonUtil.getBoolean(json, "is_deleted")); + builder.isDeleted(JsonUtil.getBoolean(jsonObj, "is_deleted")); builder.httpResponse(httpResponse); return builder.build(); diff --git a/src/main/java/com/chargebee/v4/models/pc2MigrationItemPrice/responses/Pc2MigrationItemPriceListResponse.java b/src/main/java/com/chargebee/v4/models/pc2MigrationItemPrice/responses/Pc2MigrationItemPriceListResponse.java index 913c9f05..99a9cd10 100644 --- a/src/main/java/com/chargebee/v4/models/pc2MigrationItemPrice/responses/Pc2MigrationItemPriceListResponse.java +++ b/src/main/java/com/chargebee/v4/models/pc2MigrationItemPrice/responses/Pc2MigrationItemPriceListResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.exceptions.ChargebeeException; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; import com.chargebee.v4.services.Pc2MigrationItemPriceService; import com.chargebee.v4.models.pc2MigrationItemPrice.params.Pc2MigrationItemPriceListParams; @@ -43,13 +44,12 @@ private Pc2MigrationItemPriceListResponse( */ public static Pc2MigrationItemPriceListResponse fromJson(String json) { try { + JsonObject jsonObj = JsonUtil.parse(json); List> list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(JsonUtil::parseJsonObjectToMap) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArrayToMaps(JsonUtil.getJsonArray(jsonObj, "list")); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new Pc2MigrationItemPriceListResponse(list, nextOffset, null, null, null); } catch (Exception e) { @@ -67,13 +67,12 @@ public static Pc2MigrationItemPriceListResponse fromJson( Pc2MigrationItemPriceListParams originalParams, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); List> list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(JsonUtil::parseJsonObjectToMap) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArrayToMaps(JsonUtil.getJsonArray(jsonObj, "list")); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new Pc2MigrationItemPriceListResponse( list, nextOffset, service, originalParams, httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/pc2MigrationItemPrice/responses/Pc2MigrationItemPriceRetrieveResponse.java b/src/main/java/com/chargebee/v4/models/pc2MigrationItemPrice/responses/Pc2MigrationItemPriceRetrieveResponse.java index 59edc212..4adc01e2 100644 --- a/src/main/java/com/chargebee/v4/models/pc2MigrationItemPrice/responses/Pc2MigrationItemPriceRetrieveResponse.java +++ b/src/main/java/com/chargebee/v4/models/pc2MigrationItemPrice/responses/Pc2MigrationItemPriceRetrieveResponse.java @@ -2,6 +2,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -25,9 +26,10 @@ public static Pc2MigrationItemPriceRetrieveResponse fromJson(String json) { /** Parse JSON response into Pc2MigrationItemPriceRetrieveResponse object with HTTP response. */ public static Pc2MigrationItemPriceRetrieveResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - builder.pc2MigrationItemPrice(JsonUtil.getObject(json, "pc2_migration_item_price")); + builder.pc2MigrationItemPrice(JsonUtil.getObject(jsonObj, "pc2_migration_item_price")); builder.httpResponse(httpResponse); return builder.build(); diff --git a/src/main/java/com/chargebee/v4/models/pc2MigrationItemPrice/responses/Pc2MigrationItemPriceUpdateResponse.java b/src/main/java/com/chargebee/v4/models/pc2MigrationItemPrice/responses/Pc2MigrationItemPriceUpdateResponse.java index 7afe4483..3efd68ed 100644 --- a/src/main/java/com/chargebee/v4/models/pc2MigrationItemPrice/responses/Pc2MigrationItemPriceUpdateResponse.java +++ b/src/main/java/com/chargebee/v4/models/pc2MigrationItemPrice/responses/Pc2MigrationItemPriceUpdateResponse.java @@ -1,6 +1,8 @@ package com.chargebee.v4.models.pc2MigrationItemPrice.responses; import com.chargebee.v4.models.BaseResponse; +import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -21,6 +23,7 @@ public static Pc2MigrationItemPriceUpdateResponse fromJson(String json) { /** Parse JSON response into Pc2MigrationItemPriceUpdateResponse object with HTTP response. */ public static Pc2MigrationItemPriceUpdateResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/personalizedOffer/PersonalizedOffer.java b/src/main/java/com/chargebee/v4/models/personalizedOffer/PersonalizedOffer.java index 207cb33e..fc88fa89 100644 --- a/src/main/java/com/chargebee/v4/models/personalizedOffer/PersonalizedOffer.java +++ b/src/main/java/com/chargebee/v4/models/personalizedOffer/PersonalizedOffer.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.personalizedOffer; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import java.util.List; public class PersonalizedOffer { @@ -34,21 +35,22 @@ public List getOptions() { } public static PersonalizedOffer fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static PersonalizedOffer fromJson(JsonObject jsonObj) { PersonalizedOffer obj = new PersonalizedOffer(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.offerId = JsonUtil.getString(json, "offer_id"); + obj.offerId = JsonUtil.getString(jsonObj, "offer_id"); - String __contentJson = JsonUtil.getObject(json, "content"); - if (__contentJson != null) { - obj.content = Content.fromJson(__contentJson); + JsonObject __contentObj = JsonUtil.getJsonObject(jsonObj, "content"); + if (__contentObj != null) { + obj.content = Content.fromJson(__contentObj); } - obj.options = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "options")).stream() - .map(Options::fromJson) - .collect(java.util.stream.Collectors.toList()); + obj.options = JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "options"), Options::fromJson); return obj; } @@ -99,11 +101,15 @@ public String getDescription() { } public static Content fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Content fromJson(JsonObject jsonObj) { Content obj = new Content(); - obj.title = JsonUtil.getString(json, "title"); + obj.title = JsonUtil.getString(jsonObj, "title"); - obj.description = JsonUtil.getString(json, "description"); + obj.description = JsonUtil.getString(jsonObj, "description"); return obj; } @@ -221,18 +227,23 @@ public static ProcessingLayout fromString(String value) { } public static Options fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Options fromJson(JsonObject jsonObj) { Options obj = new Options(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.label = JsonUtil.getString(json, "label"); + obj.label = JsonUtil.getString(jsonObj, "label"); - obj.processingType = ProcessingType.fromString(JsonUtil.getString(json, "processing_type")); + obj.processingType = + ProcessingType.fromString(JsonUtil.getString(jsonObj, "processing_type")); obj.processingLayout = - ProcessingLayout.fromString(JsonUtil.getString(json, "processing_layout")); + ProcessingLayout.fromString(JsonUtil.getString(jsonObj, "processing_layout")); - obj.redirectUrl = JsonUtil.getString(json, "redirect_url"); + obj.redirectUrl = JsonUtil.getString(jsonObj, "redirect_url"); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/personalizedOffer/responses/PersonalizedOffersResponse.java b/src/main/java/com/chargebee/v4/models/personalizedOffer/responses/PersonalizedOffersResponse.java index 4a07a07b..ffa21639 100644 --- a/src/main/java/com/chargebee/v4/models/personalizedOffer/responses/PersonalizedOffersResponse.java +++ b/src/main/java/com/chargebee/v4/models/personalizedOffer/responses/PersonalizedOffersResponse.java @@ -8,6 +8,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; import java.sql.Timestamp; @@ -40,19 +41,19 @@ public static PersonalizedOffersResponse fromJson(String json) { /** Parse JSON response into PersonalizedOffersResponse object with HTTP response. */ public static PersonalizedOffersResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); builder.personalizedOffers( - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "personalized_offers")).stream() - .map(PersonalizedOffer::fromJson) - .collect(java.util.stream.Collectors.toList())); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "personalized_offers"), PersonalizedOffer::fromJson)); - String __brandJson = JsonUtil.getObject(json, "brand"); - if (__brandJson != null) { - builder.brand(Brand.fromJson(__brandJson)); + JsonObject __brandObj = JsonUtil.getJsonObject(jsonObj, "brand"); + if (__brandObj != null) { + builder.brand(Brand.fromJson(__brandObj)); } - builder.expiresAt(JsonUtil.getTimestamp(json, "expires_at")); + builder.expiresAt(JsonUtil.getTimestamp(jsonObj, "expires_at")); builder.httpResponse(httpResponse); return builder.build(); diff --git a/src/main/java/com/chargebee/v4/models/plan/Plan.java b/src/main/java/com/chargebee/v4/models/plan/Plan.java index d5690c34..2bc7304e 100644 --- a/src/main/java/com/chargebee/v4/models/plan/Plan.java +++ b/src/main/java/com/chargebee/v4/models/plan/Plan.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.plan; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import java.sql.Timestamp; import java.util.List; @@ -632,9 +633,12 @@ public static Channel fromString(String value) { } public static Plan fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Plan fromJson(JsonObject jsonObj) { Plan obj = new Plan(); - // Parse JSON to extract all keys for custom field extraction java.util.Set knownFields = new java.util.HashSet<>(); knownFields.add("id"); @@ -749,176 +753,140 @@ public static Plan fromJson(String json) { knownFields.add("event_based_addons"); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.name = JsonUtil.getString(json, "name"); + obj.name = JsonUtil.getString(jsonObj, "name"); - obj.invoiceName = JsonUtil.getString(json, "invoice_name"); + obj.invoiceName = JsonUtil.getString(jsonObj, "invoice_name"); - obj.description = JsonUtil.getString(json, "description"); + obj.description = JsonUtil.getString(jsonObj, "description"); - obj.price = JsonUtil.getLong(json, "price"); + obj.price = JsonUtil.getLong(jsonObj, "price"); - obj.currencyCode = JsonUtil.getString(json, "currency_code"); + obj.currencyCode = JsonUtil.getString(jsonObj, "currency_code"); - obj.period = JsonUtil.getInteger(json, "period"); + obj.period = JsonUtil.getInteger(jsonObj, "period"); - obj.periodUnit = PeriodUnit.fromString(JsonUtil.getString(json, "period_unit")); + obj.periodUnit = PeriodUnit.fromString(JsonUtil.getString(jsonObj, "period_unit")); - obj.trialPeriod = JsonUtil.getInteger(json, "trial_period"); + obj.trialPeriod = JsonUtil.getInteger(jsonObj, "trial_period"); - obj.trialPeriodUnit = TrialPeriodUnit.fromString(JsonUtil.getString(json, "trial_period_unit")); + obj.trialPeriodUnit = + TrialPeriodUnit.fromString(JsonUtil.getString(jsonObj, "trial_period_unit")); - obj.trialEndAction = TrialEndAction.fromString(JsonUtil.getString(json, "trial_end_action")); + obj.trialEndAction = TrialEndAction.fromString(JsonUtil.getString(jsonObj, "trial_end_action")); - obj.pricingModel = PricingModel.fromString(JsonUtil.getString(json, "pricing_model")); + obj.pricingModel = PricingModel.fromString(JsonUtil.getString(jsonObj, "pricing_model")); - obj.chargeModel = ChargeModel.fromString(JsonUtil.getString(json, "charge_model")); + obj.chargeModel = ChargeModel.fromString(JsonUtil.getString(jsonObj, "charge_model")); - obj.freeQuantity = JsonUtil.getInteger(json, "free_quantity"); + obj.freeQuantity = JsonUtil.getInteger(jsonObj, "free_quantity"); - obj.setupCost = JsonUtil.getLong(json, "setup_cost"); + obj.setupCost = JsonUtil.getLong(jsonObj, "setup_cost"); - obj.downgradePenalty = JsonUtil.getDouble(json, "downgrade_penalty"); + obj.downgradePenalty = JsonUtil.getDouble(jsonObj, "downgrade_penalty"); - obj.status = Status.fromString(JsonUtil.getString(json, "status")); + obj.status = Status.fromString(JsonUtil.getString(jsonObj, "status")); - obj.archivedAt = JsonUtil.getTimestamp(json, "archived_at"); + obj.archivedAt = JsonUtil.getTimestamp(jsonObj, "archived_at"); - obj.billingCycles = JsonUtil.getInteger(json, "billing_cycles"); + obj.billingCycles = JsonUtil.getInteger(jsonObj, "billing_cycles"); - obj.redirectUrl = JsonUtil.getString(json, "redirect_url"); + obj.redirectUrl = JsonUtil.getString(jsonObj, "redirect_url"); - obj.enabledInHostedPages = JsonUtil.getBoolean(json, "enabled_in_hosted_pages"); + obj.enabledInHostedPages = JsonUtil.getBoolean(jsonObj, "enabled_in_hosted_pages"); - obj.enabledInPortal = JsonUtil.getBoolean(json, "enabled_in_portal"); + obj.enabledInPortal = JsonUtil.getBoolean(jsonObj, "enabled_in_portal"); obj.addonApplicability = - AddonApplicability.fromString(JsonUtil.getString(json, "addon_applicability")); + AddonApplicability.fromString(JsonUtil.getString(jsonObj, "addon_applicability")); - obj.taxCode = JsonUtil.getString(json, "tax_code"); + obj.taxCode = JsonUtil.getString(jsonObj, "tax_code"); - obj.hsnCode = JsonUtil.getString(json, "hsn_code"); + obj.hsnCode = JsonUtil.getString(jsonObj, "hsn_code"); - obj.taxjarProductCode = JsonUtil.getString(json, "taxjar_product_code"); + obj.taxjarProductCode = JsonUtil.getString(jsonObj, "taxjar_product_code"); - obj.avalaraSaleType = AvalaraSaleType.fromString(JsonUtil.getString(json, "avalara_sale_type")); + obj.avalaraSaleType = + AvalaraSaleType.fromString(JsonUtil.getString(jsonObj, "avalara_sale_type")); - obj.avalaraTransactionType = JsonUtil.getInteger(json, "avalara_transaction_type"); + obj.avalaraTransactionType = JsonUtil.getInteger(jsonObj, "avalara_transaction_type"); - obj.avalaraServiceType = JsonUtil.getInteger(json, "avalara_service_type"); + obj.avalaraServiceType = JsonUtil.getInteger(jsonObj, "avalara_service_type"); - obj.sku = JsonUtil.getString(json, "sku"); + obj.sku = JsonUtil.getString(jsonObj, "sku"); - obj.accountingCode = JsonUtil.getString(json, "accounting_code"); + obj.accountingCode = JsonUtil.getString(jsonObj, "accounting_code"); - obj.accountingCategory1 = JsonUtil.getString(json, "accounting_category1"); + obj.accountingCategory1 = JsonUtil.getString(jsonObj, "accounting_category1"); - obj.accountingCategory2 = JsonUtil.getString(json, "accounting_category2"); + obj.accountingCategory2 = JsonUtil.getString(jsonObj, "accounting_category2"); - obj.accountingCategory3 = JsonUtil.getString(json, "accounting_category3"); + obj.accountingCategory3 = JsonUtil.getString(jsonObj, "accounting_category3"); - obj.accountingCategory4 = JsonUtil.getString(json, "accounting_category4"); + obj.accountingCategory4 = JsonUtil.getString(jsonObj, "accounting_category4"); - obj.isShippable = JsonUtil.getBoolean(json, "is_shippable"); + obj.isShippable = JsonUtil.getBoolean(jsonObj, "is_shippable"); - obj.shippingFrequencyPeriod = JsonUtil.getInteger(json, "shipping_frequency_period"); + obj.shippingFrequencyPeriod = JsonUtil.getInteger(jsonObj, "shipping_frequency_period"); obj.shippingFrequencyPeriodUnit = ShippingFrequencyPeriodUnit.fromString( - JsonUtil.getString(json, "shipping_frequency_period_unit")); + JsonUtil.getString(jsonObj, "shipping_frequency_period_unit")); - obj.resourceVersion = JsonUtil.getLong(json, "resource_version"); + obj.resourceVersion = JsonUtil.getLong(jsonObj, "resource_version"); - obj.updatedAt = JsonUtil.getTimestamp(json, "updated_at"); + obj.updatedAt = JsonUtil.getTimestamp(jsonObj, "updated_at"); - obj.giftable = JsonUtil.getBoolean(json, "giftable"); + obj.giftable = JsonUtil.getBoolean(jsonObj, "giftable"); - obj.claimUrl = JsonUtil.getString(json, "claim_url"); + obj.claimUrl = JsonUtil.getString(jsonObj, "claim_url"); - obj.freeQuantityInDecimal = JsonUtil.getString(json, "free_quantity_in_decimal"); + obj.freeQuantityInDecimal = JsonUtil.getString(jsonObj, "free_quantity_in_decimal"); - obj.priceInDecimal = JsonUtil.getString(json, "price_in_decimal"); + obj.priceInDecimal = JsonUtil.getString(jsonObj, "price_in_decimal"); - obj.channel = Channel.fromString(JsonUtil.getString(json, "channel")); + obj.channel = Channel.fromString(JsonUtil.getString(jsonObj, "channel")); - obj.invoiceNotes = JsonUtil.getString(json, "invoice_notes"); + obj.invoiceNotes = JsonUtil.getString(jsonObj, "invoice_notes"); - obj.taxable = JsonUtil.getBoolean(json, "taxable"); + obj.taxable = JsonUtil.getBoolean(jsonObj, "taxable"); - obj.taxProfileId = JsonUtil.getString(json, "tax_profile_id"); + obj.taxProfileId = JsonUtil.getString(jsonObj, "tax_profile_id"); - String __metaDataJson = JsonUtil.getObject(json, "meta_data"); + JsonObject __metaDataObj = JsonUtil.getJsonObject(jsonObj, "meta_data"); obj.metaData = - __metaDataJson != null - ? JsonUtil.parseJsonObjectToMap(__metaDataJson) + __metaDataObj != null + ? JsonUtil.parseJsonObjectToMap(__metaDataObj) : new java.util.HashMap<>(); - obj.showDescriptionInInvoices = JsonUtil.getBoolean(json, "show_description_in_invoices"); + obj.showDescriptionInInvoices = JsonUtil.getBoolean(jsonObj, "show_description_in_invoices"); - obj.showDescriptionInQuotes = JsonUtil.getBoolean(json, "show_description_in_quotes"); + obj.showDescriptionInQuotes = JsonUtil.getBoolean(jsonObj, "show_description_in_quotes"); - obj.tiers = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "tiers")).stream() - .map(Tiers::fromJson) - .collect(java.util.stream.Collectors.toList()); + obj.tiers = JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "tiers"), Tiers::fromJson); obj.taxProvidersFields = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "tax_providers_fields")).stream() - .map(TaxProvidersFields::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "tax_providers_fields"), TaxProvidersFields::fromJson); obj.applicableAddons = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "applicable_addons")).stream() - .map(ApplicableAddons::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "applicable_addons"), ApplicableAddons::fromJson); obj.attachedAddons = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "attached_addons")).stream() - .map(AttachedAddons::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "attached_addons"), AttachedAddons::fromJson); obj.eventBasedAddons = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "event_based_addons")).stream() - .map(EventBasedAddons::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "event_based_addons"), EventBasedAddons::fromJson); - // Extract custom fields (fields starting with cf_) - obj.customFields = extractCustomFields(json, knownFields); + obj.customFields = JsonUtil.extractCustomFields(jsonObj, knownFields); return obj; } - /** - * Helper method to extract custom fields from JSON. Custom fields are fields that start with - * "cf_" and are not in the known fields set. - * - * @param json JSON string to parse - * @param knownFields set of known field names - * @return map of custom fields - */ - private static java.util.Map extractCustomFields( - String json, java.util.Set knownFields) { - java.util.Map customFields = new java.util.HashMap<>(); - try { - // Parse the entire JSON as a map - java.util.Map allFields = JsonUtil.parseJsonObjectToMap(json); - if (allFields != null) { - for (java.util.Map.Entry entry : allFields.entrySet()) { - String key = entry.getKey(); - // Include fields that start with "cf_" and are not in knownFields - if (key != null && key.startsWith("cf_") && !knownFields.contains(key)) { - customFields.put( - key, entry.getValue() != null ? String.valueOf(entry.getValue()) : null); - } - } - } - } catch (Exception e) { - // If parsing fails, return empty map - } - return customFields; - } - @Override public String toString() { return "Plan{" @@ -1241,23 +1209,27 @@ public static PricingType fromString(String value) { } public static Tiers fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Tiers fromJson(JsonObject jsonObj) { Tiers obj = new Tiers(); - obj.startingUnit = JsonUtil.getInteger(json, "starting_unit"); + obj.startingUnit = JsonUtil.getInteger(jsonObj, "starting_unit"); - obj.endingUnit = JsonUtil.getInteger(json, "ending_unit"); + obj.endingUnit = JsonUtil.getInteger(jsonObj, "ending_unit"); - obj.price = JsonUtil.getLong(json, "price"); + obj.price = JsonUtil.getLong(jsonObj, "price"); - obj.startingUnitInDecimal = JsonUtil.getString(json, "starting_unit_in_decimal"); + obj.startingUnitInDecimal = JsonUtil.getString(jsonObj, "starting_unit_in_decimal"); - obj.endingUnitInDecimal = JsonUtil.getString(json, "ending_unit_in_decimal"); + obj.endingUnitInDecimal = JsonUtil.getString(jsonObj, "ending_unit_in_decimal"); - obj.priceInDecimal = JsonUtil.getString(json, "price_in_decimal"); + obj.priceInDecimal = JsonUtil.getString(jsonObj, "price_in_decimal"); - obj.pricingType = PricingType.fromString(JsonUtil.getString(json, "pricing_type")); + obj.pricingType = PricingType.fromString(JsonUtil.getString(jsonObj, "pricing_type")); - obj.packageSize = JsonUtil.getInteger(json, "package_size"); + obj.packageSize = JsonUtil.getInteger(jsonObj, "package_size"); return obj; } @@ -1334,13 +1306,17 @@ public String getFieldValue() { } public static TaxProvidersFields fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static TaxProvidersFields fromJson(JsonObject jsonObj) { TaxProvidersFields obj = new TaxProvidersFields(); - obj.providerName = JsonUtil.getString(json, "provider_name"); + obj.providerName = JsonUtil.getString(jsonObj, "provider_name"); - obj.fieldId = JsonUtil.getString(json, "field_id"); + obj.fieldId = JsonUtil.getString(jsonObj, "field_id"); - obj.fieldValue = JsonUtil.getString(json, "field_value"); + obj.fieldValue = JsonUtil.getString(jsonObj, "field_value"); return obj; } @@ -1384,9 +1360,13 @@ public String getId() { } public static ApplicableAddons fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static ApplicableAddons fromJson(JsonObject jsonObj) { ApplicableAddons obj = new ApplicableAddons(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); return obj; } @@ -1469,17 +1449,21 @@ public static Type fromString(String value) { } public static AttachedAddons fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static AttachedAddons fromJson(JsonObject jsonObj) { AttachedAddons obj = new AttachedAddons(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.quantity = JsonUtil.getInteger(json, "quantity"); + obj.quantity = JsonUtil.getInteger(jsonObj, "quantity"); - obj.billingCycles = JsonUtil.getInteger(json, "billing_cycles"); + obj.billingCycles = JsonUtil.getInteger(jsonObj, "billing_cycles"); - obj.type = Type.fromString(JsonUtil.getString(json, "type")); + obj.type = Type.fromString(JsonUtil.getString(jsonObj, "type")); - obj.quantityInDecimal = JsonUtil.getString(json, "quantity_in_decimal"); + obj.quantityInDecimal = JsonUtil.getString(jsonObj, "quantity_in_decimal"); return obj; } @@ -1583,17 +1567,21 @@ public static OnEvent fromString(String value) { } public static EventBasedAddons fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static EventBasedAddons fromJson(JsonObject jsonObj) { EventBasedAddons obj = new EventBasedAddons(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.quantity = JsonUtil.getInteger(json, "quantity"); + obj.quantity = JsonUtil.getInteger(jsonObj, "quantity"); - obj.onEvent = OnEvent.fromString(JsonUtil.getString(json, "on_event")); + obj.onEvent = OnEvent.fromString(JsonUtil.getString(jsonObj, "on_event")); - obj.chargeOnce = JsonUtil.getBoolean(json, "charge_once"); + obj.chargeOnce = JsonUtil.getBoolean(jsonObj, "charge_once"); - obj.quantityInDecimal = JsonUtil.getString(json, "quantity_in_decimal"); + obj.quantityInDecimal = JsonUtil.getString(jsonObj, "quantity_in_decimal"); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/plan/responses/PlanCopyResponse.java b/src/main/java/com/chargebee/v4/models/plan/responses/PlanCopyResponse.java index 1523f890..3bec362a 100644 --- a/src/main/java/com/chargebee/v4/models/plan/responses/PlanCopyResponse.java +++ b/src/main/java/com/chargebee/v4/models/plan/responses/PlanCopyResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** Immutable response object for PlanCopy operation. Contains the response data from the API. */ @@ -24,11 +25,12 @@ public static PlanCopyResponse fromJson(String json) { /** Parse JSON response into PlanCopyResponse object with HTTP response. */ public static PlanCopyResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __planJson = JsonUtil.getObject(json, "plan"); - if (__planJson != null) { - builder.plan(Plan.fromJson(__planJson)); + JsonObject __planObj = JsonUtil.getJsonObject(jsonObj, "plan"); + if (__planObj != null) { + builder.plan(Plan.fromJson(__planObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/plan/responses/PlanCreateResponse.java b/src/main/java/com/chargebee/v4/models/plan/responses/PlanCreateResponse.java index 1ca2e653..e8a4fdac 100644 --- a/src/main/java/com/chargebee/v4/models/plan/responses/PlanCreateResponse.java +++ b/src/main/java/com/chargebee/v4/models/plan/responses/PlanCreateResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** Immutable response object for PlanCreate operation. Contains the response data from the API. */ @@ -24,11 +25,12 @@ public static PlanCreateResponse fromJson(String json) { /** Parse JSON response into PlanCreateResponse object with HTTP response. */ public static PlanCreateResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __planJson = JsonUtil.getObject(json, "plan"); - if (__planJson != null) { - builder.plan(Plan.fromJson(__planJson)); + JsonObject __planObj = JsonUtil.getJsonObject(jsonObj, "plan"); + if (__planObj != null) { + builder.plan(Plan.fromJson(__planObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/plan/responses/PlanDeleteResponse.java b/src/main/java/com/chargebee/v4/models/plan/responses/PlanDeleteResponse.java index fc89f4f6..baa06671 100644 --- a/src/main/java/com/chargebee/v4/models/plan/responses/PlanDeleteResponse.java +++ b/src/main/java/com/chargebee/v4/models/plan/responses/PlanDeleteResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** Immutable response object for PlanDelete operation. Contains the response data from the API. */ @@ -24,11 +25,12 @@ public static PlanDeleteResponse fromJson(String json) { /** Parse JSON response into PlanDeleteResponse object with HTTP response. */ public static PlanDeleteResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __planJson = JsonUtil.getObject(json, "plan"); - if (__planJson != null) { - builder.plan(Plan.fromJson(__planJson)); + JsonObject __planObj = JsonUtil.getJsonObject(jsonObj, "plan"); + if (__planObj != null) { + builder.plan(Plan.fromJson(__planObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/plan/responses/PlanListResponse.java b/src/main/java/com/chargebee/v4/models/plan/responses/PlanListResponse.java index 9fca28a2..34504bf8 100644 --- a/src/main/java/com/chargebee/v4/models/plan/responses/PlanListResponse.java +++ b/src/main/java/com/chargebee/v4/models/plan/responses/PlanListResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.exceptions.ChargebeeException; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; import com.chargebee.v4.services.PlanService; import com.chargebee.v4.models.plan.params.PlanListParams; @@ -43,13 +44,12 @@ private PlanListResponse( */ public static PlanListResponse fromJson(String json) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(PlanListItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "list"), PlanListItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new PlanListResponse(list, nextOffset, null, null, null); } catch (Exception e) { @@ -64,13 +64,12 @@ public static PlanListResponse fromJson(String json) { public static PlanListResponse fromJson( String json, PlanService service, PlanListParams originalParams, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(PlanListItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "list"), PlanListItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new PlanListResponse(list, nextOffset, service, originalParams, httpResponse); } catch (Exception e) { @@ -170,11 +169,15 @@ public Plan getPlan() { } public static PlanListItem fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static PlanListItem fromJson(JsonObject jsonObj) { PlanListItem item = new PlanListItem(); - String __planJson = JsonUtil.getObject(json, "plan"); - if (__planJson != null) { - item.plan = Plan.fromJson(__planJson); + JsonObject __planObj = JsonUtil.getJsonObject(jsonObj, "plan"); + if (__planObj != null) { + item.plan = Plan.fromJson(__planObj); } return item; diff --git a/src/main/java/com/chargebee/v4/models/plan/responses/PlanRetrieveResponse.java b/src/main/java/com/chargebee/v4/models/plan/responses/PlanRetrieveResponse.java index 455e59ce..818b23a7 100644 --- a/src/main/java/com/chargebee/v4/models/plan/responses/PlanRetrieveResponse.java +++ b/src/main/java/com/chargebee/v4/models/plan/responses/PlanRetrieveResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static PlanRetrieveResponse fromJson(String json) { /** Parse JSON response into PlanRetrieveResponse object with HTTP response. */ public static PlanRetrieveResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __planJson = JsonUtil.getObject(json, "plan"); - if (__planJson != null) { - builder.plan(Plan.fromJson(__planJson)); + JsonObject __planObj = JsonUtil.getJsonObject(jsonObj, "plan"); + if (__planObj != null) { + builder.plan(Plan.fromJson(__planObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/plan/responses/PlanUnarchiveResponse.java b/src/main/java/com/chargebee/v4/models/plan/responses/PlanUnarchiveResponse.java index 392e18b6..1204a772 100644 --- a/src/main/java/com/chargebee/v4/models/plan/responses/PlanUnarchiveResponse.java +++ b/src/main/java/com/chargebee/v4/models/plan/responses/PlanUnarchiveResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -26,11 +27,12 @@ public static PlanUnarchiveResponse fromJson(String json) { /** Parse JSON response into PlanUnarchiveResponse object with HTTP response. */ public static PlanUnarchiveResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __planJson = JsonUtil.getObject(json, "plan"); - if (__planJson != null) { - builder.plan(Plan.fromJson(__planJson)); + JsonObject __planObj = JsonUtil.getJsonObject(jsonObj, "plan"); + if (__planObj != null) { + builder.plan(Plan.fromJson(__planObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/plan/responses/PlanUpdateResponse.java b/src/main/java/com/chargebee/v4/models/plan/responses/PlanUpdateResponse.java index 45973064..9afb9001 100644 --- a/src/main/java/com/chargebee/v4/models/plan/responses/PlanUpdateResponse.java +++ b/src/main/java/com/chargebee/v4/models/plan/responses/PlanUpdateResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** Immutable response object for PlanUpdate operation. Contains the response data from the API. */ @@ -24,11 +25,12 @@ public static PlanUpdateResponse fromJson(String json) { /** Parse JSON response into PlanUpdateResponse object with HTTP response. */ public static PlanUpdateResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __planJson = JsonUtil.getObject(json, "plan"); - if (__planJson != null) { - builder.plan(Plan.fromJson(__planJson)); + JsonObject __planObj = JsonUtil.getJsonObject(jsonObj, "plan"); + if (__planObj != null) { + builder.plan(Plan.fromJson(__planObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/portalSession/PortalSession.java b/src/main/java/com/chargebee/v4/models/portalSession/PortalSession.java index 801ea991..1108f901 100644 --- a/src/main/java/com/chargebee/v4/models/portalSession/PortalSession.java +++ b/src/main/java/com/chargebee/v4/models/portalSession/PortalSession.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.portalSession; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import java.sql.Timestamp; import java.util.List; @@ -114,36 +115,39 @@ public static Status fromString(String value) { } public static PortalSession fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static PortalSession fromJson(JsonObject jsonObj) { PortalSession obj = new PortalSession(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.token = JsonUtil.getString(json, "token"); + obj.token = JsonUtil.getString(jsonObj, "token"); - obj.accessUrl = JsonUtil.getString(json, "access_url"); + obj.accessUrl = JsonUtil.getString(jsonObj, "access_url"); - obj.redirectUrl = JsonUtil.getString(json, "redirect_url"); + obj.redirectUrl = JsonUtil.getString(jsonObj, "redirect_url"); - obj.status = Status.fromString(JsonUtil.getString(json, "status")); + obj.status = Status.fromString(JsonUtil.getString(jsonObj, "status")); - obj.createdAt = JsonUtil.getTimestamp(json, "created_at"); + obj.createdAt = JsonUtil.getTimestamp(jsonObj, "created_at"); - obj.expiresAt = JsonUtil.getTimestamp(json, "expires_at"); + obj.expiresAt = JsonUtil.getTimestamp(jsonObj, "expires_at"); - obj.customerId = JsonUtil.getString(json, "customer_id"); + obj.customerId = JsonUtil.getString(jsonObj, "customer_id"); - obj.loginAt = JsonUtil.getTimestamp(json, "login_at"); + obj.loginAt = JsonUtil.getTimestamp(jsonObj, "login_at"); - obj.logoutAt = JsonUtil.getTimestamp(json, "logout_at"); + obj.logoutAt = JsonUtil.getTimestamp(jsonObj, "logout_at"); - obj.loginIpaddress = JsonUtil.getString(json, "login_ipaddress"); + obj.loginIpaddress = JsonUtil.getString(jsonObj, "login_ipaddress"); - obj.logoutIpaddress = JsonUtil.getString(json, "logout_ipaddress"); + obj.logoutIpaddress = JsonUtil.getString(jsonObj, "logout_ipaddress"); obj.linkedCustomers = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "linked_customers")).stream() - .map(LinkedCustomers::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "linked_customers"), LinkedCustomers::fromJson); return obj; } @@ -249,17 +253,21 @@ public Boolean getHasActiveSubscription() { } public static LinkedCustomers fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static LinkedCustomers fromJson(JsonObject jsonObj) { LinkedCustomers obj = new LinkedCustomers(); - obj.customerId = JsonUtil.getString(json, "customer_id"); + obj.customerId = JsonUtil.getString(jsonObj, "customer_id"); - obj.email = JsonUtil.getString(json, "email"); + obj.email = JsonUtil.getString(jsonObj, "email"); - obj.hasBillingAddress = JsonUtil.getBoolean(json, "has_billing_address"); + obj.hasBillingAddress = JsonUtil.getBoolean(jsonObj, "has_billing_address"); - obj.hasPaymentMethod = JsonUtil.getBoolean(json, "has_payment_method"); + obj.hasPaymentMethod = JsonUtil.getBoolean(jsonObj, "has_payment_method"); - obj.hasActiveSubscription = JsonUtil.getBoolean(json, "has_active_subscription"); + obj.hasActiveSubscription = JsonUtil.getBoolean(jsonObj, "has_active_subscription"); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/portalSession/responses/PortalSessionActivateResponse.java b/src/main/java/com/chargebee/v4/models/portalSession/responses/PortalSessionActivateResponse.java index 53c7f5b4..e406414e 100644 --- a/src/main/java/com/chargebee/v4/models/portalSession/responses/PortalSessionActivateResponse.java +++ b/src/main/java/com/chargebee/v4/models/portalSession/responses/PortalSessionActivateResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static PortalSessionActivateResponse fromJson(String json) { /** Parse JSON response into PortalSessionActivateResponse object with HTTP response. */ public static PortalSessionActivateResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __portalSessionJson = JsonUtil.getObject(json, "portal_session"); - if (__portalSessionJson != null) { - builder.portalSession(PortalSession.fromJson(__portalSessionJson)); + JsonObject __portalSessionObj = JsonUtil.getJsonObject(jsonObj, "portal_session"); + if (__portalSessionObj != null) { + builder.portalSession(PortalSession.fromJson(__portalSessionObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/portalSession/responses/PortalSessionCreateResponse.java b/src/main/java/com/chargebee/v4/models/portalSession/responses/PortalSessionCreateResponse.java index af9099ec..16ce0c84 100644 --- a/src/main/java/com/chargebee/v4/models/portalSession/responses/PortalSessionCreateResponse.java +++ b/src/main/java/com/chargebee/v4/models/portalSession/responses/PortalSessionCreateResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static PortalSessionCreateResponse fromJson(String json) { /** Parse JSON response into PortalSessionCreateResponse object with HTTP response. */ public static PortalSessionCreateResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __portalSessionJson = JsonUtil.getObject(json, "portal_session"); - if (__portalSessionJson != null) { - builder.portalSession(PortalSession.fromJson(__portalSessionJson)); + JsonObject __portalSessionObj = JsonUtil.getJsonObject(jsonObj, "portal_session"); + if (__portalSessionObj != null) { + builder.portalSession(PortalSession.fromJson(__portalSessionObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/portalSession/responses/PortalSessionLogoutResponse.java b/src/main/java/com/chargebee/v4/models/portalSession/responses/PortalSessionLogoutResponse.java index ac627280..92ee2dc1 100644 --- a/src/main/java/com/chargebee/v4/models/portalSession/responses/PortalSessionLogoutResponse.java +++ b/src/main/java/com/chargebee/v4/models/portalSession/responses/PortalSessionLogoutResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static PortalSessionLogoutResponse fromJson(String json) { /** Parse JSON response into PortalSessionLogoutResponse object with HTTP response. */ public static PortalSessionLogoutResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __portalSessionJson = JsonUtil.getObject(json, "portal_session"); - if (__portalSessionJson != null) { - builder.portalSession(PortalSession.fromJson(__portalSessionJson)); + JsonObject __portalSessionObj = JsonUtil.getJsonObject(jsonObj, "portal_session"); + if (__portalSessionObj != null) { + builder.portalSession(PortalSession.fromJson(__portalSessionObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/portalSession/responses/PortalSessionRetrieveResponse.java b/src/main/java/com/chargebee/v4/models/portalSession/responses/PortalSessionRetrieveResponse.java index cb149f6a..0fb908ac 100644 --- a/src/main/java/com/chargebee/v4/models/portalSession/responses/PortalSessionRetrieveResponse.java +++ b/src/main/java/com/chargebee/v4/models/portalSession/responses/PortalSessionRetrieveResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static PortalSessionRetrieveResponse fromJson(String json) { /** Parse JSON response into PortalSessionRetrieveResponse object with HTTP response. */ public static PortalSessionRetrieveResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __portalSessionJson = JsonUtil.getObject(json, "portal_session"); - if (__portalSessionJson != null) { - builder.portalSession(PortalSession.fromJson(__portalSessionJson)); + JsonObject __portalSessionObj = JsonUtil.getJsonObject(jsonObj, "portal_session"); + if (__portalSessionObj != null) { + builder.portalSession(PortalSession.fromJson(__portalSessionObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/priceVariant/PriceVariant.java b/src/main/java/com/chargebee/v4/models/priceVariant/PriceVariant.java index 80661edc..03620741 100644 --- a/src/main/java/com/chargebee/v4/models/priceVariant/PriceVariant.java +++ b/src/main/java/com/chargebee/v4/models/priceVariant/PriceVariant.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.priceVariant; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import java.sql.Timestamp; import java.util.List; @@ -110,36 +111,38 @@ public static Status fromString(String value) { } public static PriceVariant fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static PriceVariant fromJson(JsonObject jsonObj) { PriceVariant obj = new PriceVariant(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.name = JsonUtil.getString(json, "name"); + obj.name = JsonUtil.getString(jsonObj, "name"); - obj.externalName = JsonUtil.getString(json, "external_name"); + obj.externalName = JsonUtil.getString(jsonObj, "external_name"); - obj.variantGroup = JsonUtil.getString(json, "variant_group"); + obj.variantGroup = JsonUtil.getString(jsonObj, "variant_group"); - obj.description = JsonUtil.getString(json, "description"); + obj.description = JsonUtil.getString(jsonObj, "description"); - obj.status = Status.fromString(JsonUtil.getString(json, "status")); + obj.status = Status.fromString(JsonUtil.getString(jsonObj, "status")); - obj.createdAt = JsonUtil.getTimestamp(json, "created_at"); + obj.createdAt = JsonUtil.getTimestamp(jsonObj, "created_at"); - obj.resourceVersion = JsonUtil.getLong(json, "resource_version"); + obj.resourceVersion = JsonUtil.getLong(jsonObj, "resource_version"); - obj.updatedAt = JsonUtil.getTimestamp(json, "updated_at"); + obj.updatedAt = JsonUtil.getTimestamp(jsonObj, "updated_at"); - obj.archivedAt = JsonUtil.getTimestamp(json, "archived_at"); + obj.archivedAt = JsonUtil.getTimestamp(jsonObj, "archived_at"); - obj.businessEntityId = JsonUtil.getString(json, "business_entity_id"); + obj.businessEntityId = JsonUtil.getString(jsonObj, "business_entity_id"); - obj.deleted = JsonUtil.getBoolean(json, "deleted"); + obj.deleted = JsonUtil.getBoolean(jsonObj, "deleted"); obj.attributes = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "attributes")).stream() - .map(Attributes::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "attributes"), Attributes::fromJson); return obj; } @@ -230,11 +233,15 @@ public String getValue() { } public static Attributes fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Attributes fromJson(JsonObject jsonObj) { Attributes obj = new Attributes(); - obj.name = JsonUtil.getString(json, "name"); + obj.name = JsonUtil.getString(jsonObj, "name"); - obj.value = JsonUtil.getString(json, "value"); + obj.value = JsonUtil.getString(jsonObj, "value"); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/priceVariant/responses/PriceVariantCreateResponse.java b/src/main/java/com/chargebee/v4/models/priceVariant/responses/PriceVariantCreateResponse.java index 2b4fb9ae..e9bdff50 100644 --- a/src/main/java/com/chargebee/v4/models/priceVariant/responses/PriceVariantCreateResponse.java +++ b/src/main/java/com/chargebee/v4/models/priceVariant/responses/PriceVariantCreateResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static PriceVariantCreateResponse fromJson(String json) { /** Parse JSON response into PriceVariantCreateResponse object with HTTP response. */ public static PriceVariantCreateResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __priceVariantJson = JsonUtil.getObject(json, "price_variant"); - if (__priceVariantJson != null) { - builder.priceVariant(PriceVariant.fromJson(__priceVariantJson)); + JsonObject __priceVariantObj = JsonUtil.getJsonObject(jsonObj, "price_variant"); + if (__priceVariantObj != null) { + builder.priceVariant(PriceVariant.fromJson(__priceVariantObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/priceVariant/responses/PriceVariantDeleteResponse.java b/src/main/java/com/chargebee/v4/models/priceVariant/responses/PriceVariantDeleteResponse.java index 4c3d4960..b31ccb57 100644 --- a/src/main/java/com/chargebee/v4/models/priceVariant/responses/PriceVariantDeleteResponse.java +++ b/src/main/java/com/chargebee/v4/models/priceVariant/responses/PriceVariantDeleteResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static PriceVariantDeleteResponse fromJson(String json) { /** Parse JSON response into PriceVariantDeleteResponse object with HTTP response. */ public static PriceVariantDeleteResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __priceVariantJson = JsonUtil.getObject(json, "price_variant"); - if (__priceVariantJson != null) { - builder.priceVariant(PriceVariant.fromJson(__priceVariantJson)); + JsonObject __priceVariantObj = JsonUtil.getJsonObject(jsonObj, "price_variant"); + if (__priceVariantObj != null) { + builder.priceVariant(PriceVariant.fromJson(__priceVariantObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/priceVariant/responses/PriceVariantListResponse.java b/src/main/java/com/chargebee/v4/models/priceVariant/responses/PriceVariantListResponse.java index 22f4417f..5613fdac 100644 --- a/src/main/java/com/chargebee/v4/models/priceVariant/responses/PriceVariantListResponse.java +++ b/src/main/java/com/chargebee/v4/models/priceVariant/responses/PriceVariantListResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.exceptions.ChargebeeException; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; import com.chargebee.v4.services.PriceVariantService; import com.chargebee.v4.models.priceVariant.params.PriceVariantListParams; @@ -43,13 +44,12 @@ private PriceVariantListResponse( */ public static PriceVariantListResponse fromJson(String json) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(PriceVariantListItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "list"), PriceVariantListItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new PriceVariantListResponse(list, nextOffset, null, null, null); } catch (Exception e) { @@ -67,13 +67,12 @@ public static PriceVariantListResponse fromJson( PriceVariantListParams originalParams, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(PriceVariantListItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "list"), PriceVariantListItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new PriceVariantListResponse(list, nextOffset, service, originalParams, httpResponse); } catch (Exception e) { @@ -173,11 +172,15 @@ public PriceVariant getPriceVariant() { } public static PriceVariantListItem fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static PriceVariantListItem fromJson(JsonObject jsonObj) { PriceVariantListItem item = new PriceVariantListItem(); - String __priceVariantJson = JsonUtil.getObject(json, "price_variant"); - if (__priceVariantJson != null) { - item.priceVariant = PriceVariant.fromJson(__priceVariantJson); + JsonObject __priceVariantObj = JsonUtil.getJsonObject(jsonObj, "price_variant"); + if (__priceVariantObj != null) { + item.priceVariant = PriceVariant.fromJson(__priceVariantObj); } return item; diff --git a/src/main/java/com/chargebee/v4/models/priceVariant/responses/PriceVariantRetrieveResponse.java b/src/main/java/com/chargebee/v4/models/priceVariant/responses/PriceVariantRetrieveResponse.java index f9564522..929e4e53 100644 --- a/src/main/java/com/chargebee/v4/models/priceVariant/responses/PriceVariantRetrieveResponse.java +++ b/src/main/java/com/chargebee/v4/models/priceVariant/responses/PriceVariantRetrieveResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static PriceVariantRetrieveResponse fromJson(String json) { /** Parse JSON response into PriceVariantRetrieveResponse object with HTTP response. */ public static PriceVariantRetrieveResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __priceVariantJson = JsonUtil.getObject(json, "price_variant"); - if (__priceVariantJson != null) { - builder.priceVariant(PriceVariant.fromJson(__priceVariantJson)); + JsonObject __priceVariantObj = JsonUtil.getJsonObject(jsonObj, "price_variant"); + if (__priceVariantObj != null) { + builder.priceVariant(PriceVariant.fromJson(__priceVariantObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/priceVariant/responses/PriceVariantUpdateResponse.java b/src/main/java/com/chargebee/v4/models/priceVariant/responses/PriceVariantUpdateResponse.java index 07ba0272..0f59abc9 100644 --- a/src/main/java/com/chargebee/v4/models/priceVariant/responses/PriceVariantUpdateResponse.java +++ b/src/main/java/com/chargebee/v4/models/priceVariant/responses/PriceVariantUpdateResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static PriceVariantUpdateResponse fromJson(String json) { /** Parse JSON response into PriceVariantUpdateResponse object with HTTP response. */ public static PriceVariantUpdateResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __priceVariantJson = JsonUtil.getObject(json, "price_variant"); - if (__priceVariantJson != null) { - builder.priceVariant(PriceVariant.fromJson(__priceVariantJson)); + JsonObject __priceVariantObj = JsonUtil.getJsonObject(jsonObj, "price_variant"); + if (__priceVariantObj != null) { + builder.priceVariant(PriceVariant.fromJson(__priceVariantObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/pricingPageSession/PricingPageSession.java b/src/main/java/com/chargebee/v4/models/pricingPageSession/PricingPageSession.java index 4e3d1981..f3b367e4 100644 --- a/src/main/java/com/chargebee/v4/models/pricingPageSession/PricingPageSession.java +++ b/src/main/java/com/chargebee/v4/models/pricingPageSession/PricingPageSession.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.pricingPageSession; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import java.sql.Timestamp; public class PricingPageSession { @@ -34,15 +35,19 @@ public Timestamp getExpiresAt() { } public static PricingPageSession fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static PricingPageSession fromJson(JsonObject jsonObj) { PricingPageSession obj = new PricingPageSession(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.url = JsonUtil.getString(json, "url"); + obj.url = JsonUtil.getString(jsonObj, "url"); - obj.createdAt = JsonUtil.getTimestamp(json, "created_at"); + obj.createdAt = JsonUtil.getTimestamp(jsonObj, "created_at"); - obj.expiresAt = JsonUtil.getTimestamp(json, "expires_at"); + obj.expiresAt = JsonUtil.getTimestamp(jsonObj, "expires_at"); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/pricingPageSession/responses/PricingPageSessionCreateForExistingSubscriptionResponse.java b/src/main/java/com/chargebee/v4/models/pricingPageSession/responses/PricingPageSessionCreateForExistingSubscriptionResponse.java index b75e4e0c..3f10964c 100644 --- a/src/main/java/com/chargebee/v4/models/pricingPageSession/responses/PricingPageSessionCreateForExistingSubscriptionResponse.java +++ b/src/main/java/com/chargebee/v4/models/pricingPageSession/responses/PricingPageSessionCreateForExistingSubscriptionResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -31,11 +32,12 @@ public static PricingPageSessionCreateForExistingSubscriptionResponse fromJson(S public static PricingPageSessionCreateForExistingSubscriptionResponse fromJson( String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __pricingPageSessionJson = JsonUtil.getObject(json, "pricing_page_session"); - if (__pricingPageSessionJson != null) { - builder.pricingPageSession(PricingPageSession.fromJson(__pricingPageSessionJson)); + JsonObject __pricingPageSessionObj = JsonUtil.getJsonObject(jsonObj, "pricing_page_session"); + if (__pricingPageSessionObj != null) { + builder.pricingPageSession(PricingPageSession.fromJson(__pricingPageSessionObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/pricingPageSession/responses/PricingPageSessionCreateForNewSubscriptionResponse.java b/src/main/java/com/chargebee/v4/models/pricingPageSession/responses/PricingPageSessionCreateForNewSubscriptionResponse.java index 5cd20dc3..976e45d7 100644 --- a/src/main/java/com/chargebee/v4/models/pricingPageSession/responses/PricingPageSessionCreateForNewSubscriptionResponse.java +++ b/src/main/java/com/chargebee/v4/models/pricingPageSession/responses/PricingPageSessionCreateForNewSubscriptionResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -31,11 +32,12 @@ public static PricingPageSessionCreateForNewSubscriptionResponse fromJson(String public static PricingPageSessionCreateForNewSubscriptionResponse fromJson( String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __pricingPageSessionJson = JsonUtil.getObject(json, "pricing_page_session"); - if (__pricingPageSessionJson != null) { - builder.pricingPageSession(PricingPageSession.fromJson(__pricingPageSessionJson)); + JsonObject __pricingPageSessionObj = JsonUtil.getJsonObject(jsonObj, "pricing_page_session"); + if (__pricingPageSessionObj != null) { + builder.pricingPageSession(PricingPageSession.fromJson(__pricingPageSessionObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/product/Product.java b/src/main/java/com/chargebee/v4/models/product/Product.java index e6b8dfc8..c8be5bae 100644 --- a/src/main/java/com/chargebee/v4/models/product/Product.java +++ b/src/main/java/com/chargebee/v4/models/product/Product.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.product; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import java.sql.Timestamp; import java.util.List; @@ -113,42 +114,43 @@ public static Status fromString(String value) { } public static Product fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Product fromJson(JsonObject jsonObj) { Product obj = new Product(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.name = JsonUtil.getString(json, "name"); + obj.name = JsonUtil.getString(jsonObj, "name"); - obj.externalName = JsonUtil.getString(json, "external_name"); + obj.externalName = JsonUtil.getString(jsonObj, "external_name"); - obj.description = JsonUtil.getString(json, "description"); + obj.description = JsonUtil.getString(jsonObj, "description"); - obj.hasVariant = JsonUtil.getBoolean(json, "has_variant"); + obj.hasVariant = JsonUtil.getBoolean(jsonObj, "has_variant"); - obj.status = Status.fromString(JsonUtil.getString(json, "status")); + obj.status = Status.fromString(JsonUtil.getString(jsonObj, "status")); - obj.shippable = JsonUtil.getBoolean(json, "shippable"); + obj.shippable = JsonUtil.getBoolean(jsonObj, "shippable"); - obj.sku = JsonUtil.getString(json, "sku"); + obj.sku = JsonUtil.getString(jsonObj, "sku"); - obj.createdAt = JsonUtil.getTimestamp(json, "created_at"); + obj.createdAt = JsonUtil.getTimestamp(jsonObj, "created_at"); - obj.resourceVersion = JsonUtil.getLong(json, "resource_version"); + obj.resourceVersion = JsonUtil.getLong(jsonObj, "resource_version"); - obj.updatedAt = JsonUtil.getTimestamp(json, "updated_at"); + obj.updatedAt = JsonUtil.getTimestamp(jsonObj, "updated_at"); - obj.deleted = JsonUtil.getBoolean(json, "deleted"); + obj.deleted = JsonUtil.getBoolean(jsonObj, "deleted"); - String __metadataJson = JsonUtil.getObject(json, "metadata"); + JsonObject __metadataObj = JsonUtil.getJsonObject(jsonObj, "metadata"); obj.metadata = - __metadataJson != null - ? JsonUtil.parseJsonObjectToMap(__metadataJson) + __metadataObj != null + ? JsonUtil.parseJsonObjectToMap(__metadataObj) : new java.util.HashMap<>(); - obj.options = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "options")).stream() - .map(Options::fromJson) - .collect(java.util.stream.Collectors.toList()); + obj.options = JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "options"), Options::fromJson); return obj; } @@ -284,23 +286,21 @@ public static Type fromString(String value) { } public static Options fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Options fromJson(JsonObject jsonObj) { Options obj = new Options(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.name = JsonUtil.getString(json, "name"); + obj.name = JsonUtil.getString(jsonObj, "name"); - String __valuesJson = JsonUtil.getArray(json, "values"); - obj.values = - __valuesJson != null - ? JsonUtil.parseObjectArray(__valuesJson).stream() - .map(JsonUtil::parseJsonObjectToMap) - .collect(java.util.stream.Collectors.toList()) - : null; + obj.values = JsonUtil.mapArrayToObjects(JsonUtil.getJsonArray(jsonObj, "values")); - obj.defaultValue = JsonUtil.getString(json, "default_value"); + obj.defaultValue = JsonUtil.getString(jsonObj, "default_value"); - obj.type = Type.fromString(JsonUtil.getString(json, "type")); + obj.type = Type.fromString(JsonUtil.getString(jsonObj, "type")); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/product/responses/ProductCreateResponse.java b/src/main/java/com/chargebee/v4/models/product/responses/ProductCreateResponse.java index afe71fe2..a920a7ea 100644 --- a/src/main/java/com/chargebee/v4/models/product/responses/ProductCreateResponse.java +++ b/src/main/java/com/chargebee/v4/models/product/responses/ProductCreateResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -26,11 +27,12 @@ public static ProductCreateResponse fromJson(String json) { /** Parse JSON response into ProductCreateResponse object with HTTP response. */ public static ProductCreateResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __productJson = JsonUtil.getObject(json, "product"); - if (__productJson != null) { - builder.product(Product.fromJson(__productJson)); + JsonObject __productObj = JsonUtil.getJsonObject(jsonObj, "product"); + if (__productObj != null) { + builder.product(Product.fromJson(__productObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/product/responses/ProductDeleteResponse.java b/src/main/java/com/chargebee/v4/models/product/responses/ProductDeleteResponse.java index 6b210e6f..cf0cb2cc 100644 --- a/src/main/java/com/chargebee/v4/models/product/responses/ProductDeleteResponse.java +++ b/src/main/java/com/chargebee/v4/models/product/responses/ProductDeleteResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -26,11 +27,12 @@ public static ProductDeleteResponse fromJson(String json) { /** Parse JSON response into ProductDeleteResponse object with HTTP response. */ public static ProductDeleteResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __productJson = JsonUtil.getObject(json, "product"); - if (__productJson != null) { - builder.product(Product.fromJson(__productJson)); + JsonObject __productObj = JsonUtil.getJsonObject(jsonObj, "product"); + if (__productObj != null) { + builder.product(Product.fromJson(__productObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/product/responses/ProductListResponse.java b/src/main/java/com/chargebee/v4/models/product/responses/ProductListResponse.java index 8e6968a5..5e533c68 100644 --- a/src/main/java/com/chargebee/v4/models/product/responses/ProductListResponse.java +++ b/src/main/java/com/chargebee/v4/models/product/responses/ProductListResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.exceptions.ChargebeeException; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; import com.chargebee.v4.services.ProductService; import com.chargebee.v4.models.product.params.ProductListParams; @@ -43,13 +44,12 @@ private ProductListResponse( */ public static ProductListResponse fromJson(String json) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(ProductListItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "list"), ProductListItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new ProductListResponse(list, nextOffset, null, null, null); } catch (Exception e) { @@ -67,13 +67,12 @@ public static ProductListResponse fromJson( ProductListParams originalParams, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(ProductListItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "list"), ProductListItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new ProductListResponse(list, nextOffset, service, originalParams, httpResponse); } catch (Exception e) { @@ -173,11 +172,15 @@ public Product getProduct() { } public static ProductListItem fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static ProductListItem fromJson(JsonObject jsonObj) { ProductListItem item = new ProductListItem(); - String __productJson = JsonUtil.getObject(json, "product"); - if (__productJson != null) { - item.product = Product.fromJson(__productJson); + JsonObject __productObj = JsonUtil.getJsonObject(jsonObj, "product"); + if (__productObj != null) { + item.product = Product.fromJson(__productObj); } return item; diff --git a/src/main/java/com/chargebee/v4/models/product/responses/ProductRetrieveResponse.java b/src/main/java/com/chargebee/v4/models/product/responses/ProductRetrieveResponse.java index 4dbeea66..4296e536 100644 --- a/src/main/java/com/chargebee/v4/models/product/responses/ProductRetrieveResponse.java +++ b/src/main/java/com/chargebee/v4/models/product/responses/ProductRetrieveResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static ProductRetrieveResponse fromJson(String json) { /** Parse JSON response into ProductRetrieveResponse object with HTTP response. */ public static ProductRetrieveResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __productJson = JsonUtil.getObject(json, "product"); - if (__productJson != null) { - builder.product(Product.fromJson(__productJson)); + JsonObject __productObj = JsonUtil.getJsonObject(jsonObj, "product"); + if (__productObj != null) { + builder.product(Product.fromJson(__productObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/product/responses/ProductUpdateOptionsResponse.java b/src/main/java/com/chargebee/v4/models/product/responses/ProductUpdateOptionsResponse.java index da45e3a7..d92011ef 100644 --- a/src/main/java/com/chargebee/v4/models/product/responses/ProductUpdateOptionsResponse.java +++ b/src/main/java/com/chargebee/v4/models/product/responses/ProductUpdateOptionsResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static ProductUpdateOptionsResponse fromJson(String json) { /** Parse JSON response into ProductUpdateOptionsResponse object with HTTP response. */ public static ProductUpdateOptionsResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __productJson = JsonUtil.getObject(json, "product"); - if (__productJson != null) { - builder.product(Product.fromJson(__productJson)); + JsonObject __productObj = JsonUtil.getJsonObject(jsonObj, "product"); + if (__productObj != null) { + builder.product(Product.fromJson(__productObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/product/responses/ProductUpdateResponse.java b/src/main/java/com/chargebee/v4/models/product/responses/ProductUpdateResponse.java index f5916a7f..d75a8310 100644 --- a/src/main/java/com/chargebee/v4/models/product/responses/ProductUpdateResponse.java +++ b/src/main/java/com/chargebee/v4/models/product/responses/ProductUpdateResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -26,11 +27,12 @@ public static ProductUpdateResponse fromJson(String json) { /** Parse JSON response into ProductUpdateResponse object with HTTP response. */ public static ProductUpdateResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __productJson = JsonUtil.getObject(json, "product"); - if (__productJson != null) { - builder.product(Product.fromJson(__productJson)); + JsonObject __productObj = JsonUtil.getJsonObject(jsonObj, "product"); + if (__productObj != null) { + builder.product(Product.fromJson(__productObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/promotionalCredit/PromotionalCredit.java b/src/main/java/com/chargebee/v4/models/promotionalCredit/PromotionalCredit.java index e13c6649..83481fc5 100644 --- a/src/main/java/com/chargebee/v4/models/promotionalCredit/PromotionalCredit.java +++ b/src/main/java/com/chargebee/v4/models/promotionalCredit/PromotionalCredit.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.promotionalCredit; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import java.sql.Timestamp; public class PromotionalCredit { @@ -137,33 +138,37 @@ public static CreditType fromString(String value) { } public static PromotionalCredit fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static PromotionalCredit fromJson(JsonObject jsonObj) { PromotionalCredit obj = new PromotionalCredit(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.customerId = JsonUtil.getString(json, "customer_id"); + obj.customerId = JsonUtil.getString(jsonObj, "customer_id"); - obj.type = Type.fromString(JsonUtil.getString(json, "type")); + obj.type = Type.fromString(JsonUtil.getString(jsonObj, "type")); - obj.amountInDecimal = JsonUtil.getString(json, "amount_in_decimal"); + obj.amountInDecimal = JsonUtil.getString(jsonObj, "amount_in_decimal"); - obj.amount = JsonUtil.getLong(json, "amount"); + obj.amount = JsonUtil.getLong(jsonObj, "amount"); - obj.currencyCode = JsonUtil.getString(json, "currency_code"); + obj.currencyCode = JsonUtil.getString(jsonObj, "currency_code"); - obj.description = JsonUtil.getString(json, "description"); + obj.description = JsonUtil.getString(jsonObj, "description"); - obj.creditType = CreditType.fromString(JsonUtil.getString(json, "credit_type")); + obj.creditType = CreditType.fromString(JsonUtil.getString(jsonObj, "credit_type")); - obj.reference = JsonUtil.getString(json, "reference"); + obj.reference = JsonUtil.getString(jsonObj, "reference"); - obj.closingBalance = JsonUtil.getLong(json, "closing_balance"); + obj.closingBalance = JsonUtil.getLong(jsonObj, "closing_balance"); - obj.doneBy = JsonUtil.getString(json, "done_by"); + obj.doneBy = JsonUtil.getString(jsonObj, "done_by"); - obj.createdAt = JsonUtil.getTimestamp(json, "created_at"); + obj.createdAt = JsonUtil.getTimestamp(jsonObj, "created_at"); - obj.businessEntityId = JsonUtil.getString(json, "business_entity_id"); + obj.businessEntityId = JsonUtil.getString(jsonObj, "business_entity_id"); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/promotionalCredit/responses/PromotionalCreditAddResponse.java b/src/main/java/com/chargebee/v4/models/promotionalCredit/responses/PromotionalCreditAddResponse.java index c72a4760..e3c27079 100644 --- a/src/main/java/com/chargebee/v4/models/promotionalCredit/responses/PromotionalCreditAddResponse.java +++ b/src/main/java/com/chargebee/v4/models/promotionalCredit/responses/PromotionalCreditAddResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -33,16 +34,17 @@ public static PromotionalCreditAddResponse fromJson(String json) { /** Parse JSON response into PromotionalCreditAddResponse object with HTTP response. */ public static PromotionalCreditAddResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - builder.customer(Customer.fromJson(__customerJson)); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + builder.customer(Customer.fromJson(__customerObj)); } - String __promotionalCreditJson = JsonUtil.getObject(json, "promotional_credit"); - if (__promotionalCreditJson != null) { - builder.promotionalCredit(PromotionalCredit.fromJson(__promotionalCreditJson)); + JsonObject __promotionalCreditObj = JsonUtil.getJsonObject(jsonObj, "promotional_credit"); + if (__promotionalCreditObj != null) { + builder.promotionalCredit(PromotionalCredit.fromJson(__promotionalCreditObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/promotionalCredit/responses/PromotionalCreditDeductResponse.java b/src/main/java/com/chargebee/v4/models/promotionalCredit/responses/PromotionalCreditDeductResponse.java index 0b594ed2..c2879317 100644 --- a/src/main/java/com/chargebee/v4/models/promotionalCredit/responses/PromotionalCreditDeductResponse.java +++ b/src/main/java/com/chargebee/v4/models/promotionalCredit/responses/PromotionalCreditDeductResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -33,16 +34,17 @@ public static PromotionalCreditDeductResponse fromJson(String json) { /** Parse JSON response into PromotionalCreditDeductResponse object with HTTP response. */ public static PromotionalCreditDeductResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - builder.customer(Customer.fromJson(__customerJson)); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + builder.customer(Customer.fromJson(__customerObj)); } - String __promotionalCreditJson = JsonUtil.getObject(json, "promotional_credit"); - if (__promotionalCreditJson != null) { - builder.promotionalCredit(PromotionalCredit.fromJson(__promotionalCreditJson)); + JsonObject __promotionalCreditObj = JsonUtil.getJsonObject(jsonObj, "promotional_credit"); + if (__promotionalCreditObj != null) { + builder.promotionalCredit(PromotionalCredit.fromJson(__promotionalCreditObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/promotionalCredit/responses/PromotionalCreditListResponse.java b/src/main/java/com/chargebee/v4/models/promotionalCredit/responses/PromotionalCreditListResponse.java index 0bd2b20e..b9367576 100644 --- a/src/main/java/com/chargebee/v4/models/promotionalCredit/responses/PromotionalCreditListResponse.java +++ b/src/main/java/com/chargebee/v4/models/promotionalCredit/responses/PromotionalCreditListResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.exceptions.ChargebeeException; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; import com.chargebee.v4.services.PromotionalCreditService; import com.chargebee.v4.models.promotionalCredit.params.PromotionalCreditListParams; @@ -43,13 +44,13 @@ private PromotionalCreditListResponse( */ public static PromotionalCreditListResponse fromJson(String json) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(PromotionalCreditListItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "list"), PromotionalCreditListItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new PromotionalCreditListResponse(list, nextOffset, null, null, null); } catch (Exception e) { @@ -67,13 +68,13 @@ public static PromotionalCreditListResponse fromJson( PromotionalCreditListParams originalParams, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(PromotionalCreditListItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "list"), PromotionalCreditListItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new PromotionalCreditListResponse( list, nextOffset, service, originalParams, httpResponse); @@ -176,11 +177,15 @@ public PromotionalCredit getPromotionalCredit() { } public static PromotionalCreditListItem fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static PromotionalCreditListItem fromJson(JsonObject jsonObj) { PromotionalCreditListItem item = new PromotionalCreditListItem(); - String __promotionalCreditJson = JsonUtil.getObject(json, "promotional_credit"); - if (__promotionalCreditJson != null) { - item.promotionalCredit = PromotionalCredit.fromJson(__promotionalCreditJson); + JsonObject __promotionalCreditObj = JsonUtil.getJsonObject(jsonObj, "promotional_credit"); + if (__promotionalCreditObj != null) { + item.promotionalCredit = PromotionalCredit.fromJson(__promotionalCreditObj); } return item; diff --git a/src/main/java/com/chargebee/v4/models/promotionalCredit/responses/PromotionalCreditRetrieveResponse.java b/src/main/java/com/chargebee/v4/models/promotionalCredit/responses/PromotionalCreditRetrieveResponse.java index 377a173c..4025da7d 100644 --- a/src/main/java/com/chargebee/v4/models/promotionalCredit/responses/PromotionalCreditRetrieveResponse.java +++ b/src/main/java/com/chargebee/v4/models/promotionalCredit/responses/PromotionalCreditRetrieveResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static PromotionalCreditRetrieveResponse fromJson(String json) { /** Parse JSON response into PromotionalCreditRetrieveResponse object with HTTP response. */ public static PromotionalCreditRetrieveResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __promotionalCreditJson = JsonUtil.getObject(json, "promotional_credit"); - if (__promotionalCreditJson != null) { - builder.promotionalCredit(PromotionalCredit.fromJson(__promotionalCreditJson)); + JsonObject __promotionalCreditObj = JsonUtil.getJsonObject(jsonObj, "promotional_credit"); + if (__promotionalCreditObj != null) { + builder.promotionalCredit(PromotionalCredit.fromJson(__promotionalCreditObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/promotionalCredit/responses/PromotionalCreditSetResponse.java b/src/main/java/com/chargebee/v4/models/promotionalCredit/responses/PromotionalCreditSetResponse.java index 7dac9e1c..d468db2f 100644 --- a/src/main/java/com/chargebee/v4/models/promotionalCredit/responses/PromotionalCreditSetResponse.java +++ b/src/main/java/com/chargebee/v4/models/promotionalCredit/responses/PromotionalCreditSetResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -33,16 +34,17 @@ public static PromotionalCreditSetResponse fromJson(String json) { /** Parse JSON response into PromotionalCreditSetResponse object with HTTP response. */ public static PromotionalCreditSetResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - builder.customer(Customer.fromJson(__customerJson)); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + builder.customer(Customer.fromJson(__customerObj)); } - String __promotionalCreditJson = JsonUtil.getObject(json, "promotional_credit"); - if (__promotionalCreditJson != null) { - builder.promotionalCredit(PromotionalCredit.fromJson(__promotionalCreditJson)); + JsonObject __promotionalCreditObj = JsonUtil.getJsonObject(jsonObj, "promotional_credit"); + if (__promotionalCreditObj != null) { + builder.promotionalCredit(PromotionalCredit.fromJson(__promotionalCreditObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/purchase/Purchase.java b/src/main/java/com/chargebee/v4/models/purchase/Purchase.java index fd73817e..3d7de675 100644 --- a/src/main/java/com/chargebee/v4/models/purchase/Purchase.java +++ b/src/main/java/com/chargebee/v4/models/purchase/Purchase.java @@ -8,6 +8,8 @@ package com.chargebee.v4.models.purchase; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonArray; +import com.google.gson.JsonObject; import java.sql.Timestamp; import java.util.List; @@ -45,19 +47,29 @@ public List getInvoiceIds() { } public static Purchase fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Purchase fromJson(JsonObject jsonObj) { Purchase obj = new Purchase(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.customerId = JsonUtil.getString(json, "customer_id"); + obj.customerId = JsonUtil.getString(jsonObj, "customer_id"); - obj.createdAt = JsonUtil.getTimestamp(json, "created_at"); + obj.createdAt = JsonUtil.getTimestamp(jsonObj, "created_at"); - obj.modifiedAt = JsonUtil.getTimestamp(json, "modified_at"); + obj.modifiedAt = JsonUtil.getTimestamp(jsonObj, "modified_at"); - obj.subscriptionIds = JsonUtil.parseArrayOfString(JsonUtil.getArray(json, "subscription_ids")); + JsonArray __subscriptionIdsArr = JsonUtil.getJsonArray(jsonObj, "subscription_ids"); + if (__subscriptionIdsArr != null) { + obj.subscriptionIds = JsonUtil.parseArrayOfString(__subscriptionIdsArr); + } - obj.invoiceIds = JsonUtil.parseArrayOfString(JsonUtil.getArray(json, "invoice_ids")); + JsonArray __invoiceIdsArr = JsonUtil.getJsonArray(jsonObj, "invoice_ids"); + if (__invoiceIdsArr != null) { + obj.invoiceIds = JsonUtil.parseArrayOfString(__invoiceIdsArr); + } return obj; } diff --git a/src/main/java/com/chargebee/v4/models/purchase/responses/PurchaseCreateResponse.java b/src/main/java/com/chargebee/v4/models/purchase/responses/PurchaseCreateResponse.java index 2592f099..83a54bc4 100644 --- a/src/main/java/com/chargebee/v4/models/purchase/responses/PurchaseCreateResponse.java +++ b/src/main/java/com/chargebee/v4/models/purchase/responses/PurchaseCreateResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -26,11 +27,12 @@ public static PurchaseCreateResponse fromJson(String json) { /** Parse JSON response into PurchaseCreateResponse object with HTTP response. */ public static PurchaseCreateResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __purchaseJson = JsonUtil.getObject(json, "purchase"); - if (__purchaseJson != null) { - builder.purchase(Purchase.fromJson(__purchaseJson)); + JsonObject __purchaseObj = JsonUtil.getJsonObject(jsonObj, "purchase"); + if (__purchaseObj != null) { + builder.purchase(Purchase.fromJson(__purchaseObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/purchase/responses/PurchaseEstimateResponse.java b/src/main/java/com/chargebee/v4/models/purchase/responses/PurchaseEstimateResponse.java index c7643a36..534ae7d2 100644 --- a/src/main/java/com/chargebee/v4/models/purchase/responses/PurchaseEstimateResponse.java +++ b/src/main/java/com/chargebee/v4/models/purchase/responses/PurchaseEstimateResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static PurchaseEstimateResponse fromJson(String json) { /** Parse JSON response into PurchaseEstimateResponse object with HTTP response. */ public static PurchaseEstimateResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __estimateJson = JsonUtil.getObject(json, "estimate"); - if (__estimateJson != null) { - builder.estimate(Estimate.fromJson(__estimateJson)); + JsonObject __estimateObj = JsonUtil.getJsonObject(jsonObj, "estimate"); + if (__estimateObj != null) { + builder.estimate(Estimate.fromJson(__estimateObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/quote/Quote.java b/src/main/java/com/chargebee/v4/models/quote/Quote.java index be1c4980..3007983d 100644 --- a/src/main/java/com/chargebee/v4/models/quote/Quote.java +++ b/src/main/java/com/chargebee/v4/models/quote/Quote.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.quote; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import java.math.BigDecimal; import java.sql.Timestamp; import java.util.List; @@ -347,9 +348,12 @@ public static PriceType fromString(String value) { } public static Quote fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Quote fromJson(JsonObject jsonObj) { Quote obj = new Quote(); - // Parse JSON to extract all keys for custom field extraction java.util.Set knownFields = new java.util.HashSet<>(); knownFields.add("id"); @@ -434,154 +438,107 @@ public static Quote fromJson(String json) { knownFields.add("billing_address"); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.name = JsonUtil.getString(json, "name"); + obj.name = JsonUtil.getString(jsonObj, "name"); - obj.poNumber = JsonUtil.getString(json, "po_number"); + obj.poNumber = JsonUtil.getString(jsonObj, "po_number"); - obj.customerId = JsonUtil.getString(json, "customer_id"); + obj.customerId = JsonUtil.getString(jsonObj, "customer_id"); - obj.subscriptionId = JsonUtil.getString(json, "subscription_id"); + obj.subscriptionId = JsonUtil.getString(jsonObj, "subscription_id"); - obj.invoiceId = JsonUtil.getString(json, "invoice_id"); + obj.invoiceId = JsonUtil.getString(jsonObj, "invoice_id"); - obj.status = Status.fromString(JsonUtil.getString(json, "status")); + obj.status = Status.fromString(JsonUtil.getString(jsonObj, "status")); - obj.operationType = OperationType.fromString(JsonUtil.getString(json, "operation_type")); + obj.operationType = OperationType.fromString(JsonUtil.getString(jsonObj, "operation_type")); - obj.vatNumber = JsonUtil.getString(json, "vat_number"); + obj.vatNumber = JsonUtil.getString(jsonObj, "vat_number"); - obj.priceType = PriceType.fromString(JsonUtil.getString(json, "price_type")); + obj.priceType = PriceType.fromString(JsonUtil.getString(jsonObj, "price_type")); - obj.validTill = JsonUtil.getTimestamp(json, "valid_till"); + obj.validTill = JsonUtil.getTimestamp(jsonObj, "valid_till"); - obj.date = JsonUtil.getTimestamp(json, "date"); + obj.date = JsonUtil.getTimestamp(jsonObj, "date"); - obj.totalPayable = JsonUtil.getLong(json, "total_payable"); + obj.totalPayable = JsonUtil.getLong(jsonObj, "total_payable"); - obj.chargeOnAcceptance = JsonUtil.getLong(json, "charge_on_acceptance"); + obj.chargeOnAcceptance = JsonUtil.getLong(jsonObj, "charge_on_acceptance"); - obj.subTotal = JsonUtil.getLong(json, "sub_total"); + obj.subTotal = JsonUtil.getLong(jsonObj, "sub_total"); - obj.total = JsonUtil.getLong(json, "total"); + obj.total = JsonUtil.getLong(jsonObj, "total"); - obj.creditsApplied = JsonUtil.getLong(json, "credits_applied"); + obj.creditsApplied = JsonUtil.getLong(jsonObj, "credits_applied"); - obj.amountPaid = JsonUtil.getLong(json, "amount_paid"); + obj.amountPaid = JsonUtil.getLong(jsonObj, "amount_paid"); - obj.amountDue = JsonUtil.getLong(json, "amount_due"); + obj.amountDue = JsonUtil.getLong(jsonObj, "amount_due"); - obj.version = JsonUtil.getInteger(json, "version"); + obj.version = JsonUtil.getInteger(jsonObj, "version"); - obj.resourceVersion = JsonUtil.getLong(json, "resource_version"); + obj.resourceVersion = JsonUtil.getLong(jsonObj, "resource_version"); - obj.updatedAt = JsonUtil.getTimestamp(json, "updated_at"); + obj.updatedAt = JsonUtil.getTimestamp(jsonObj, "updated_at"); - obj.vatNumberPrefix = JsonUtil.getString(json, "vat_number_prefix"); + obj.vatNumberPrefix = JsonUtil.getString(jsonObj, "vat_number_prefix"); - obj.taxCategory = JsonUtil.getString(json, "tax_category"); + obj.taxCategory = JsonUtil.getString(jsonObj, "tax_category"); - obj.currencyCode = JsonUtil.getString(json, "currency_code"); + obj.currencyCode = JsonUtil.getString(jsonObj, "currency_code"); - String __notesJson = JsonUtil.getArray(json, "notes"); - obj.notes = - __notesJson != null - ? JsonUtil.parseObjectArray(__notesJson).stream() - .map(JsonUtil::parseJsonObjectToMap) - .collect(java.util.stream.Collectors.toList()) - : null; + obj.notes = JsonUtil.mapArrayToObjects(JsonUtil.getJsonArray(jsonObj, "notes")); - obj.contractTermStart = JsonUtil.getTimestamp(json, "contract_term_start"); + obj.contractTermStart = JsonUtil.getTimestamp(jsonObj, "contract_term_start"); - obj.contractTermEnd = JsonUtil.getTimestamp(json, "contract_term_end"); + obj.contractTermEnd = JsonUtil.getTimestamp(jsonObj, "contract_term_end"); - obj.contractTermTerminationFee = JsonUtil.getLong(json, "contract_term_termination_fee"); + obj.contractTermTerminationFee = JsonUtil.getLong(jsonObj, "contract_term_termination_fee"); - obj.businessEntityId = JsonUtil.getString(json, "business_entity_id"); + obj.businessEntityId = JsonUtil.getString(jsonObj, "business_entity_id"); - obj.deleted = JsonUtil.getBoolean(json, "deleted"); + obj.deleted = JsonUtil.getBoolean(jsonObj, "deleted"); - obj.totalContractValue = JsonUtil.getLong(json, "total_contract_value"); + obj.totalContractValue = JsonUtil.getLong(jsonObj, "total_contract_value"); - obj.totalDiscount = JsonUtil.getLong(json, "total_discount"); + obj.totalDiscount = JsonUtil.getLong(jsonObj, "total_discount"); obj.lineItems = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "line_items")).stream() - .map(LineItems::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "line_items"), LineItems::fromJson); obj.lineItemTiers = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "line_item_tiers")).stream() - .map(LineItemTiers::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "line_item_tiers"), LineItemTiers::fromJson); obj.lineItemDiscounts = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "line_item_discounts")).stream() - .map(LineItemDiscounts::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "line_item_discounts"), LineItemDiscounts::fromJson); obj.lineItemTaxes = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "line_item_taxes")).stream() - .map(LineItemTaxes::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "line_item_taxes"), LineItemTaxes::fromJson); obj.discounts = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "discounts")).stream() - .map(Discounts::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "discounts"), Discounts::fromJson); - obj.taxes = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "taxes")).stream() - .map(Taxes::fromJson) - .collect(java.util.stream.Collectors.toList()); + obj.taxes = JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "taxes"), Taxes::fromJson); - String __shippingAddressJson = JsonUtil.getObject(json, "shipping_address"); - if (__shippingAddressJson != null) { - obj.shippingAddress = ShippingAddress.fromJson(__shippingAddressJson); + JsonObject __shippingAddressObj = JsonUtil.getJsonObject(jsonObj, "shipping_address"); + if (__shippingAddressObj != null) { + obj.shippingAddress = ShippingAddress.fromJson(__shippingAddressObj); } - String __billingAddressJson = JsonUtil.getObject(json, "billing_address"); - if (__billingAddressJson != null) { - obj.billingAddress = BillingAddress.fromJson(__billingAddressJson); + JsonObject __billingAddressObj = JsonUtil.getJsonObject(jsonObj, "billing_address"); + if (__billingAddressObj != null) { + obj.billingAddress = BillingAddress.fromJson(__billingAddressObj); } - // Extract custom fields (fields starting with cf_) - obj.customFields = extractCustomFields(json, knownFields); + obj.customFields = JsonUtil.extractCustomFields(jsonObj, knownFields); return obj; } - /** - * Helper method to extract custom fields from JSON. Custom fields are fields that start with - * "cf_" and are not in the known fields set. - * - * @param json JSON string to parse - * @param knownFields set of known field names - * @return map of custom fields - */ - private static java.util.Map extractCustomFields( - String json, java.util.Set knownFields) { - java.util.Map customFields = new java.util.HashMap<>(); - try { - // Parse the entire JSON as a map - java.util.Map allFields = JsonUtil.parseJsonObjectToMap(json); - if (allFields != null) { - for (java.util.Map.Entry entry : allFields.entrySet()) { - String key = entry.getKey(); - // Include fields that start with "cf_" and are not in knownFields - if (key != null && key.startsWith("cf_") && !knownFields.contains(key)) { - customFields.put( - key, entry.getValue() != null ? String.valueOf(entry.getValue()) : null); - } - } - } - } catch (Exception e) { - // If parsing fails, return empty map - } - return customFields; - } - @Override public String toString() { return "Quote{" @@ -1015,58 +972,62 @@ public static TaxExemptReason fromString(String value) { } public static LineItems fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static LineItems fromJson(JsonObject jsonObj) { LineItems obj = new LineItems(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.subscriptionId = JsonUtil.getString(json, "subscription_id"); + obj.subscriptionId = JsonUtil.getString(jsonObj, "subscription_id"); - obj.dateFrom = JsonUtil.getTimestamp(json, "date_from"); + obj.dateFrom = JsonUtil.getTimestamp(jsonObj, "date_from"); - obj.dateTo = JsonUtil.getTimestamp(json, "date_to"); + obj.dateTo = JsonUtil.getTimestamp(jsonObj, "date_to"); - obj.unitAmount = JsonUtil.getLong(json, "unit_amount"); + obj.unitAmount = JsonUtil.getLong(jsonObj, "unit_amount"); - obj.quantity = JsonUtil.getInteger(json, "quantity"); + obj.quantity = JsonUtil.getInteger(jsonObj, "quantity"); - obj.amount = JsonUtil.getLong(json, "amount"); + obj.amount = JsonUtil.getLong(jsonObj, "amount"); - obj.pricingModel = PricingModel.fromString(JsonUtil.getString(json, "pricing_model")); + obj.pricingModel = PricingModel.fromString(JsonUtil.getString(jsonObj, "pricing_model")); - obj.isTaxed = JsonUtil.getBoolean(json, "is_taxed"); + obj.isTaxed = JsonUtil.getBoolean(jsonObj, "is_taxed"); - obj.taxAmount = JsonUtil.getLong(json, "tax_amount"); + obj.taxAmount = JsonUtil.getLong(jsonObj, "tax_amount"); - obj.taxRate = JsonUtil.getDouble(json, "tax_rate"); + obj.taxRate = JsonUtil.getDouble(jsonObj, "tax_rate"); - obj.unitAmountInDecimal = JsonUtil.getString(json, "unit_amount_in_decimal"); + obj.unitAmountInDecimal = JsonUtil.getString(jsonObj, "unit_amount_in_decimal"); - obj.quantityInDecimal = JsonUtil.getString(json, "quantity_in_decimal"); + obj.quantityInDecimal = JsonUtil.getString(jsonObj, "quantity_in_decimal"); - obj.amountInDecimal = JsonUtil.getString(json, "amount_in_decimal"); + obj.amountInDecimal = JsonUtil.getString(jsonObj, "amount_in_decimal"); - obj.discountAmount = JsonUtil.getLong(json, "discount_amount"); + obj.discountAmount = JsonUtil.getLong(jsonObj, "discount_amount"); - obj.itemLevelDiscountAmount = JsonUtil.getLong(json, "item_level_discount_amount"); + obj.itemLevelDiscountAmount = JsonUtil.getLong(jsonObj, "item_level_discount_amount"); - obj.metered = JsonUtil.getBoolean(json, "metered"); + obj.metered = JsonUtil.getBoolean(jsonObj, "metered"); - obj.isPercentagePricing = JsonUtil.getBoolean(json, "is_percentage_pricing"); + obj.isPercentagePricing = JsonUtil.getBoolean(jsonObj, "is_percentage_pricing"); - obj.referenceLineItemId = JsonUtil.getString(json, "reference_line_item_id"); + obj.referenceLineItemId = JsonUtil.getString(jsonObj, "reference_line_item_id"); - obj.description = JsonUtil.getString(json, "description"); + obj.description = JsonUtil.getString(jsonObj, "description"); - obj.entityDescription = JsonUtil.getString(json, "entity_description"); + obj.entityDescription = JsonUtil.getString(jsonObj, "entity_description"); - obj.entityType = EntityType.fromString(JsonUtil.getString(json, "entity_type")); + obj.entityType = EntityType.fromString(JsonUtil.getString(jsonObj, "entity_type")); obj.taxExemptReason = - TaxExemptReason.fromString(JsonUtil.getString(json, "tax_exempt_reason")); + TaxExemptReason.fromString(JsonUtil.getString(jsonObj, "tax_exempt_reason")); - obj.entityId = JsonUtil.getString(json, "entity_id"); + obj.entityId = JsonUtil.getString(jsonObj, "entity_id"); - obj.customerId = JsonUtil.getString(json, "customer_id"); + obj.customerId = JsonUtil.getString(jsonObj, "customer_id"); return obj; } @@ -1281,29 +1242,33 @@ public static PricingType fromString(String value) { } public static LineItemTiers fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static LineItemTiers fromJson(JsonObject jsonObj) { LineItemTiers obj = new LineItemTiers(); - obj.lineItemId = JsonUtil.getString(json, "line_item_id"); + obj.lineItemId = JsonUtil.getString(jsonObj, "line_item_id"); - obj.startingUnit = JsonUtil.getInteger(json, "starting_unit"); + obj.startingUnit = JsonUtil.getInteger(jsonObj, "starting_unit"); - obj.endingUnit = JsonUtil.getInteger(json, "ending_unit"); + obj.endingUnit = JsonUtil.getInteger(jsonObj, "ending_unit"); - obj.quantityUsed = JsonUtil.getInteger(json, "quantity_used"); + obj.quantityUsed = JsonUtil.getInteger(jsonObj, "quantity_used"); - obj.unitAmount = JsonUtil.getLong(json, "unit_amount"); + obj.unitAmount = JsonUtil.getLong(jsonObj, "unit_amount"); - obj.startingUnitInDecimal = JsonUtil.getString(json, "starting_unit_in_decimal"); + obj.startingUnitInDecimal = JsonUtil.getString(jsonObj, "starting_unit_in_decimal"); - obj.endingUnitInDecimal = JsonUtil.getString(json, "ending_unit_in_decimal"); + obj.endingUnitInDecimal = JsonUtil.getString(jsonObj, "ending_unit_in_decimal"); - obj.quantityUsedInDecimal = JsonUtil.getString(json, "quantity_used_in_decimal"); + obj.quantityUsedInDecimal = JsonUtil.getString(jsonObj, "quantity_used_in_decimal"); - obj.unitAmountInDecimal = JsonUtil.getString(json, "unit_amount_in_decimal"); + obj.unitAmountInDecimal = JsonUtil.getString(jsonObj, "unit_amount_in_decimal"); - obj.pricingType = PricingType.fromString(JsonUtil.getString(json, "pricing_type")); + obj.pricingType = PricingType.fromString(JsonUtil.getString(jsonObj, "pricing_type")); - obj.packageSize = JsonUtil.getInteger(json, "package_size"); + obj.packageSize = JsonUtil.getInteger(jsonObj, "package_size"); return obj; } @@ -1438,17 +1403,21 @@ public static DiscountType fromString(String value) { } public static LineItemDiscounts fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static LineItemDiscounts fromJson(JsonObject jsonObj) { LineItemDiscounts obj = new LineItemDiscounts(); - obj.lineItemId = JsonUtil.getString(json, "line_item_id"); + obj.lineItemId = JsonUtil.getString(jsonObj, "line_item_id"); - obj.discountType = DiscountType.fromString(JsonUtil.getString(json, "discount_type")); + obj.discountType = DiscountType.fromString(JsonUtil.getString(jsonObj, "discount_type")); - obj.couponId = JsonUtil.getString(json, "coupon_id"); + obj.couponId = JsonUtil.getString(jsonObj, "coupon_id"); - obj.entityId = JsonUtil.getString(json, "entity_id"); + obj.entityId = JsonUtil.getString(jsonObj, "entity_id"); - obj.discountAmount = JsonUtil.getLong(json, "discount_amount"); + obj.discountAmount = JsonUtil.getLong(jsonObj, "discount_amount"); return obj; } @@ -1608,37 +1577,41 @@ public static TaxJurisType fromString(String value) { } public static LineItemTaxes fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static LineItemTaxes fromJson(JsonObject jsonObj) { LineItemTaxes obj = new LineItemTaxes(); - obj.lineItemId = JsonUtil.getString(json, "line_item_id"); + obj.lineItemId = JsonUtil.getString(jsonObj, "line_item_id"); - obj.taxName = JsonUtil.getString(json, "tax_name"); + obj.taxName = JsonUtil.getString(jsonObj, "tax_name"); - obj.taxRate = JsonUtil.getDouble(json, "tax_rate"); + obj.taxRate = JsonUtil.getDouble(jsonObj, "tax_rate"); - obj.dateTo = JsonUtil.getTimestamp(json, "date_to"); + obj.dateTo = JsonUtil.getTimestamp(jsonObj, "date_to"); - obj.dateFrom = JsonUtil.getTimestamp(json, "date_from"); + obj.dateFrom = JsonUtil.getTimestamp(jsonObj, "date_from"); - obj.proratedTaxableAmount = JsonUtil.getBigDecimal(json, "prorated_taxable_amount"); + obj.proratedTaxableAmount = JsonUtil.getBigDecimal(jsonObj, "prorated_taxable_amount"); - obj.isPartialTaxApplied = JsonUtil.getBoolean(json, "is_partial_tax_applied"); + obj.isPartialTaxApplied = JsonUtil.getBoolean(jsonObj, "is_partial_tax_applied"); - obj.isNonComplianceTax = JsonUtil.getBoolean(json, "is_non_compliance_tax"); + obj.isNonComplianceTax = JsonUtil.getBoolean(jsonObj, "is_non_compliance_tax"); - obj.taxableAmount = JsonUtil.getLong(json, "taxable_amount"); + obj.taxableAmount = JsonUtil.getLong(jsonObj, "taxable_amount"); - obj.taxAmount = JsonUtil.getLong(json, "tax_amount"); + obj.taxAmount = JsonUtil.getLong(jsonObj, "tax_amount"); - obj.taxJurisType = TaxJurisType.fromString(JsonUtil.getString(json, "tax_juris_type")); + obj.taxJurisType = TaxJurisType.fromString(JsonUtil.getString(jsonObj, "tax_juris_type")); - obj.taxJurisName = JsonUtil.getString(json, "tax_juris_name"); + obj.taxJurisName = JsonUtil.getString(jsonObj, "tax_juris_name"); - obj.taxJurisCode = JsonUtil.getString(json, "tax_juris_code"); + obj.taxJurisCode = JsonUtil.getString(jsonObj, "tax_juris_code"); - obj.taxAmountInLocalCurrency = JsonUtil.getLong(json, "tax_amount_in_local_currency"); + obj.taxAmountInLocalCurrency = JsonUtil.getLong(jsonObj, "tax_amount_in_local_currency"); - obj.localCurrencyCode = JsonUtil.getString(json, "local_currency_code"); + obj.localCurrencyCode = JsonUtil.getString(jsonObj, "local_currency_code"); return obj; } @@ -1827,21 +1800,25 @@ public static DiscountType fromString(String value) { } public static Discounts fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Discounts fromJson(JsonObject jsonObj) { Discounts obj = new Discounts(); - obj.amount = JsonUtil.getLong(json, "amount"); + obj.amount = JsonUtil.getLong(jsonObj, "amount"); - obj.description = JsonUtil.getString(json, "description"); + obj.description = JsonUtil.getString(jsonObj, "description"); - obj.lineItemId = JsonUtil.getString(json, "line_item_id"); + obj.lineItemId = JsonUtil.getString(jsonObj, "line_item_id"); - obj.entityType = EntityType.fromString(JsonUtil.getString(json, "entity_type")); + obj.entityType = EntityType.fromString(JsonUtil.getString(jsonObj, "entity_type")); - obj.discountType = DiscountType.fromString(JsonUtil.getString(json, "discount_type")); + obj.discountType = DiscountType.fromString(JsonUtil.getString(jsonObj, "discount_type")); - obj.entityId = JsonUtil.getString(json, "entity_id"); + obj.entityId = JsonUtil.getString(jsonObj, "entity_id"); - obj.couponSetCode = JsonUtil.getString(json, "coupon_set_code"); + obj.couponSetCode = JsonUtil.getString(jsonObj, "coupon_set_code"); return obj; } @@ -1908,13 +1885,17 @@ public String getDescription() { } public static Taxes fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Taxes fromJson(JsonObject jsonObj) { Taxes obj = new Taxes(); - obj.name = JsonUtil.getString(json, "name"); + obj.name = JsonUtil.getString(jsonObj, "name"); - obj.amount = JsonUtil.getLong(json, "amount"); + obj.amount = JsonUtil.getLong(jsonObj, "amount"); - obj.description = JsonUtil.getString(json, "description"); + obj.description = JsonUtil.getString(jsonObj, "description"); return obj; } @@ -2055,36 +2036,40 @@ public static ValidationStatus fromString(String value) { } public static ShippingAddress fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static ShippingAddress fromJson(JsonObject jsonObj) { ShippingAddress obj = new ShippingAddress(); - obj.firstName = JsonUtil.getString(json, "first_name"); + obj.firstName = JsonUtil.getString(jsonObj, "first_name"); - obj.lastName = JsonUtil.getString(json, "last_name"); + obj.lastName = JsonUtil.getString(jsonObj, "last_name"); - obj.email = JsonUtil.getString(json, "email"); + obj.email = JsonUtil.getString(jsonObj, "email"); - obj.company = JsonUtil.getString(json, "company"); + obj.company = JsonUtil.getString(jsonObj, "company"); - obj.phone = JsonUtil.getString(json, "phone"); + obj.phone = JsonUtil.getString(jsonObj, "phone"); - obj.line1 = JsonUtil.getString(json, "line1"); + obj.line1 = JsonUtil.getString(jsonObj, "line1"); - obj.line2 = JsonUtil.getString(json, "line2"); + obj.line2 = JsonUtil.getString(jsonObj, "line2"); - obj.line3 = JsonUtil.getString(json, "line3"); + obj.line3 = JsonUtil.getString(jsonObj, "line3"); - obj.city = JsonUtil.getString(json, "city"); + obj.city = JsonUtil.getString(jsonObj, "city"); - obj.stateCode = JsonUtil.getString(json, "state_code"); + obj.stateCode = JsonUtil.getString(jsonObj, "state_code"); - obj.state = JsonUtil.getString(json, "state"); + obj.state = JsonUtil.getString(jsonObj, "state"); - obj.country = JsonUtil.getString(json, "country"); + obj.country = JsonUtil.getString(jsonObj, "country"); - obj.zip = JsonUtil.getString(json, "zip"); + obj.zip = JsonUtil.getString(jsonObj, "zip"); obj.validationStatus = - ValidationStatus.fromString(JsonUtil.getString(json, "validation_status")); + ValidationStatus.fromString(JsonUtil.getString(jsonObj, "validation_status")); return obj; } @@ -2272,36 +2257,40 @@ public static ValidationStatus fromString(String value) { } public static BillingAddress fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static BillingAddress fromJson(JsonObject jsonObj) { BillingAddress obj = new BillingAddress(); - obj.firstName = JsonUtil.getString(json, "first_name"); + obj.firstName = JsonUtil.getString(jsonObj, "first_name"); - obj.lastName = JsonUtil.getString(json, "last_name"); + obj.lastName = JsonUtil.getString(jsonObj, "last_name"); - obj.email = JsonUtil.getString(json, "email"); + obj.email = JsonUtil.getString(jsonObj, "email"); - obj.company = JsonUtil.getString(json, "company"); + obj.company = JsonUtil.getString(jsonObj, "company"); - obj.phone = JsonUtil.getString(json, "phone"); + obj.phone = JsonUtil.getString(jsonObj, "phone"); - obj.line1 = JsonUtil.getString(json, "line1"); + obj.line1 = JsonUtil.getString(jsonObj, "line1"); - obj.line2 = JsonUtil.getString(json, "line2"); + obj.line2 = JsonUtil.getString(jsonObj, "line2"); - obj.line3 = JsonUtil.getString(json, "line3"); + obj.line3 = JsonUtil.getString(jsonObj, "line3"); - obj.city = JsonUtil.getString(json, "city"); + obj.city = JsonUtil.getString(jsonObj, "city"); - obj.stateCode = JsonUtil.getString(json, "state_code"); + obj.stateCode = JsonUtil.getString(jsonObj, "state_code"); - obj.state = JsonUtil.getString(json, "state"); + obj.state = JsonUtil.getString(jsonObj, "state"); - obj.country = JsonUtil.getString(json, "country"); + obj.country = JsonUtil.getString(jsonObj, "country"); - obj.zip = JsonUtil.getString(json, "zip"); + obj.zip = JsonUtil.getString(jsonObj, "zip"); obj.validationStatus = - ValidationStatus.fromString(JsonUtil.getString(json, "validation_status")); + ValidationStatus.fromString(JsonUtil.getString(jsonObj, "validation_status")); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/quote/responses/CreateSubscriptionForCustomerQuoteResponse.java b/src/main/java/com/chargebee/v4/models/quote/responses/CreateSubscriptionForCustomerQuoteResponse.java index 61439ad7..73422f03 100644 --- a/src/main/java/com/chargebee/v4/models/quote/responses/CreateSubscriptionForCustomerQuoteResponse.java +++ b/src/main/java/com/chargebee/v4/models/quote/responses/CreateSubscriptionForCustomerQuoteResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -36,16 +37,17 @@ public static CreateSubscriptionForCustomerQuoteResponse fromJson(String json) { public static CreateSubscriptionForCustomerQuoteResponse fromJson( String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __quoteJson = JsonUtil.getObject(json, "quote"); - if (__quoteJson != null) { - builder.quote(Quote.fromJson(__quoteJson)); + JsonObject __quoteObj = JsonUtil.getJsonObject(jsonObj, "quote"); + if (__quoteObj != null) { + builder.quote(Quote.fromJson(__quoteObj)); } - String __quotedSubscriptionJson = JsonUtil.getObject(json, "quoted_subscription"); - if (__quotedSubscriptionJson != null) { - builder.quotedSubscription(QuotedSubscription.fromJson(__quotedSubscriptionJson)); + JsonObject __quotedSubscriptionObj = JsonUtil.getJsonObject(jsonObj, "quoted_subscription"); + if (__quotedSubscriptionObj != null) { + builder.quotedSubscription(QuotedSubscription.fromJson(__quotedSubscriptionObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/quote/responses/CreateSubscriptionItemsForCustomerQuoteResponse.java b/src/main/java/com/chargebee/v4/models/quote/responses/CreateSubscriptionItemsForCustomerQuoteResponse.java index 85dbd8a5..e9d5fd8f 100644 --- a/src/main/java/com/chargebee/v4/models/quote/responses/CreateSubscriptionItemsForCustomerQuoteResponse.java +++ b/src/main/java/com/chargebee/v4/models/quote/responses/CreateSubscriptionItemsForCustomerQuoteResponse.java @@ -8,6 +8,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -43,21 +44,22 @@ public static CreateSubscriptionItemsForCustomerQuoteResponse fromJson(String js public static CreateSubscriptionItemsForCustomerQuoteResponse fromJson( String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __quoteJson = JsonUtil.getObject(json, "quote"); - if (__quoteJson != null) { - builder.quote(Quote.fromJson(__quoteJson)); + JsonObject __quoteObj = JsonUtil.getJsonObject(jsonObj, "quote"); + if (__quoteObj != null) { + builder.quote(Quote.fromJson(__quoteObj)); } - String __quotedSubscriptionJson = JsonUtil.getObject(json, "quoted_subscription"); - if (__quotedSubscriptionJson != null) { - builder.quotedSubscription(QuotedSubscription.fromJson(__quotedSubscriptionJson)); + JsonObject __quotedSubscriptionObj = JsonUtil.getJsonObject(jsonObj, "quoted_subscription"); + if (__quotedSubscriptionObj != null) { + builder.quotedSubscription(QuotedSubscription.fromJson(__quotedSubscriptionObj)); } - String __quotedRampJson = JsonUtil.getObject(json, "quoted_ramp"); - if (__quotedRampJson != null) { - builder.quotedRamp(QuotedRamp.fromJson(__quotedRampJson)); + JsonObject __quotedRampObj = JsonUtil.getJsonObject(jsonObj, "quoted_ramp"); + if (__quotedRampObj != null) { + builder.quotedRamp(QuotedRamp.fromJson(__quotedRampObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/quote/responses/EditCreateSubscriptionCustomerQuoteForItemsResponse.java b/src/main/java/com/chargebee/v4/models/quote/responses/EditCreateSubscriptionCustomerQuoteForItemsResponse.java index 4558835b..e4e6edbe 100644 --- a/src/main/java/com/chargebee/v4/models/quote/responses/EditCreateSubscriptionCustomerQuoteForItemsResponse.java +++ b/src/main/java/com/chargebee/v4/models/quote/responses/EditCreateSubscriptionCustomerQuoteForItemsResponse.java @@ -8,6 +8,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -43,21 +44,22 @@ public static EditCreateSubscriptionCustomerQuoteForItemsResponse fromJson(Strin public static EditCreateSubscriptionCustomerQuoteForItemsResponse fromJson( String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __quoteJson = JsonUtil.getObject(json, "quote"); - if (__quoteJson != null) { - builder.quote(Quote.fromJson(__quoteJson)); + JsonObject __quoteObj = JsonUtil.getJsonObject(jsonObj, "quote"); + if (__quoteObj != null) { + builder.quote(Quote.fromJson(__quoteObj)); } - String __quotedSubscriptionJson = JsonUtil.getObject(json, "quoted_subscription"); - if (__quotedSubscriptionJson != null) { - builder.quotedSubscription(QuotedSubscription.fromJson(__quotedSubscriptionJson)); + JsonObject __quotedSubscriptionObj = JsonUtil.getJsonObject(jsonObj, "quoted_subscription"); + if (__quotedSubscriptionObj != null) { + builder.quotedSubscription(QuotedSubscription.fromJson(__quotedSubscriptionObj)); } - String __quotedRampJson = JsonUtil.getObject(json, "quoted_ramp"); - if (__quotedRampJson != null) { - builder.quotedRamp(QuotedRamp.fromJson(__quotedRampJson)); + JsonObject __quotedRampObj = JsonUtil.getJsonObject(jsonObj, "quoted_ramp"); + if (__quotedRampObj != null) { + builder.quotedRamp(QuotedRamp.fromJson(__quotedRampObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/quote/responses/EditCreateSubscriptionForCustomerQuoteResponse.java b/src/main/java/com/chargebee/v4/models/quote/responses/EditCreateSubscriptionForCustomerQuoteResponse.java index 0dbfa311..6f63d742 100644 --- a/src/main/java/com/chargebee/v4/models/quote/responses/EditCreateSubscriptionForCustomerQuoteResponse.java +++ b/src/main/java/com/chargebee/v4/models/quote/responses/EditCreateSubscriptionForCustomerQuoteResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -37,16 +38,17 @@ public static EditCreateSubscriptionForCustomerQuoteResponse fromJson(String jso public static EditCreateSubscriptionForCustomerQuoteResponse fromJson( String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __quoteJson = JsonUtil.getObject(json, "quote"); - if (__quoteJson != null) { - builder.quote(Quote.fromJson(__quoteJson)); + JsonObject __quoteObj = JsonUtil.getJsonObject(jsonObj, "quote"); + if (__quoteObj != null) { + builder.quote(Quote.fromJson(__quoteObj)); } - String __quotedSubscriptionJson = JsonUtil.getObject(json, "quoted_subscription"); - if (__quotedSubscriptionJson != null) { - builder.quotedSubscription(QuotedSubscription.fromJson(__quotedSubscriptionJson)); + JsonObject __quotedSubscriptionObj = JsonUtil.getJsonObject(jsonObj, "quoted_subscription"); + if (__quotedSubscriptionObj != null) { + builder.quotedSubscription(QuotedSubscription.fromJson(__quotedSubscriptionObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/quote/responses/EditOneTimeQuoteResponse.java b/src/main/java/com/chargebee/v4/models/quote/responses/EditOneTimeQuoteResponse.java index b2b81634..5c11fc87 100644 --- a/src/main/java/com/chargebee/v4/models/quote/responses/EditOneTimeQuoteResponse.java +++ b/src/main/java/com/chargebee/v4/models/quote/responses/EditOneTimeQuoteResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -33,16 +34,17 @@ public static EditOneTimeQuoteResponse fromJson(String json) { /** Parse JSON response into EditOneTimeQuoteResponse object with HTTP response. */ public static EditOneTimeQuoteResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __quoteJson = JsonUtil.getObject(json, "quote"); - if (__quoteJson != null) { - builder.quote(Quote.fromJson(__quoteJson)); + JsonObject __quoteObj = JsonUtil.getJsonObject(jsonObj, "quote"); + if (__quoteObj != null) { + builder.quote(Quote.fromJson(__quoteObj)); } - String __quotedChargeJson = JsonUtil.getObject(json, "quoted_charge"); - if (__quotedChargeJson != null) { - builder.quotedCharge(QuotedCharge.fromJson(__quotedChargeJson)); + JsonObject __quotedChargeObj = JsonUtil.getJsonObject(jsonObj, "quoted_charge"); + if (__quotedChargeObj != null) { + builder.quotedCharge(QuotedCharge.fromJson(__quotedChargeObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/quote/responses/EditUpdateSubscriptionQuoteForItemsResponse.java b/src/main/java/com/chargebee/v4/models/quote/responses/EditUpdateSubscriptionQuoteForItemsResponse.java index d59127cf..af2ad5d1 100644 --- a/src/main/java/com/chargebee/v4/models/quote/responses/EditUpdateSubscriptionQuoteForItemsResponse.java +++ b/src/main/java/com/chargebee/v4/models/quote/responses/EditUpdateSubscriptionQuoteForItemsResponse.java @@ -8,6 +8,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -42,21 +43,22 @@ public static EditUpdateSubscriptionQuoteForItemsResponse fromJson(String json) public static EditUpdateSubscriptionQuoteForItemsResponse fromJson( String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __quoteJson = JsonUtil.getObject(json, "quote"); - if (__quoteJson != null) { - builder.quote(Quote.fromJson(__quoteJson)); + JsonObject __quoteObj = JsonUtil.getJsonObject(jsonObj, "quote"); + if (__quoteObj != null) { + builder.quote(Quote.fromJson(__quoteObj)); } - String __quotedSubscriptionJson = JsonUtil.getObject(json, "quoted_subscription"); - if (__quotedSubscriptionJson != null) { - builder.quotedSubscription(QuotedSubscription.fromJson(__quotedSubscriptionJson)); + JsonObject __quotedSubscriptionObj = JsonUtil.getJsonObject(jsonObj, "quoted_subscription"); + if (__quotedSubscriptionObj != null) { + builder.quotedSubscription(QuotedSubscription.fromJson(__quotedSubscriptionObj)); } - String __quotedRampJson = JsonUtil.getObject(json, "quoted_ramp"); - if (__quotedRampJson != null) { - builder.quotedRamp(QuotedRamp.fromJson(__quotedRampJson)); + JsonObject __quotedRampObj = JsonUtil.getJsonObject(jsonObj, "quoted_ramp"); + if (__quotedRampObj != null) { + builder.quotedRamp(QuotedRamp.fromJson(__quotedRampObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/quote/responses/EditUpdateSubscriptionQuoteResponse.java b/src/main/java/com/chargebee/v4/models/quote/responses/EditUpdateSubscriptionQuoteResponse.java index b5552761..84ca502b 100644 --- a/src/main/java/com/chargebee/v4/models/quote/responses/EditUpdateSubscriptionQuoteResponse.java +++ b/src/main/java/com/chargebee/v4/models/quote/responses/EditUpdateSubscriptionQuoteResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -33,16 +34,17 @@ public static EditUpdateSubscriptionQuoteResponse fromJson(String json) { /** Parse JSON response into EditUpdateSubscriptionQuoteResponse object with HTTP response. */ public static EditUpdateSubscriptionQuoteResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __quoteJson = JsonUtil.getObject(json, "quote"); - if (__quoteJson != null) { - builder.quote(Quote.fromJson(__quoteJson)); + JsonObject __quoteObj = JsonUtil.getJsonObject(jsonObj, "quote"); + if (__quoteObj != null) { + builder.quote(Quote.fromJson(__quoteObj)); } - String __quotedSubscriptionJson = JsonUtil.getObject(json, "quoted_subscription"); - if (__quotedSubscriptionJson != null) { - builder.quotedSubscription(QuotedSubscription.fromJson(__quotedSubscriptionJson)); + JsonObject __quotedSubscriptionObj = JsonUtil.getJsonObject(jsonObj, "quoted_subscription"); + if (__quotedSubscriptionObj != null) { + builder.quotedSubscription(QuotedSubscription.fromJson(__quotedSubscriptionObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/quote/responses/QuoteConvertResponse.java b/src/main/java/com/chargebee/v4/models/quote/responses/QuoteConvertResponse.java index 4928d967..c0af56fe 100644 --- a/src/main/java/com/chargebee/v4/models/quote/responses/QuoteConvertResponse.java +++ b/src/main/java/com/chargebee/v4/models/quote/responses/QuoteConvertResponse.java @@ -22,6 +22,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -76,52 +77,52 @@ public static QuoteConvertResponse fromJson(String json) { /** Parse JSON response into QuoteConvertResponse object with HTTP response. */ public static QuoteConvertResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __quoteJson = JsonUtil.getObject(json, "quote"); - if (__quoteJson != null) { - builder.quote(Quote.fromJson(__quoteJson)); + JsonObject __quoteObj = JsonUtil.getJsonObject(jsonObj, "quote"); + if (__quoteObj != null) { + builder.quote(Quote.fromJson(__quoteObj)); } - String __quotedSubscriptionJson = JsonUtil.getObject(json, "quoted_subscription"); - if (__quotedSubscriptionJson != null) { - builder.quotedSubscription(QuotedSubscription.fromJson(__quotedSubscriptionJson)); + JsonObject __quotedSubscriptionObj = JsonUtil.getJsonObject(jsonObj, "quoted_subscription"); + if (__quotedSubscriptionObj != null) { + builder.quotedSubscription(QuotedSubscription.fromJson(__quotedSubscriptionObj)); } - String __quotedChargeJson = JsonUtil.getObject(json, "quoted_charge"); - if (__quotedChargeJson != null) { - builder.quotedCharge(QuotedCharge.fromJson(__quotedChargeJson)); + JsonObject __quotedChargeObj = JsonUtil.getJsonObject(jsonObj, "quoted_charge"); + if (__quotedChargeObj != null) { + builder.quotedCharge(QuotedCharge.fromJson(__quotedChargeObj)); } - String __quotedRampJson = JsonUtil.getObject(json, "quoted_ramp"); - if (__quotedRampJson != null) { - builder.quotedRamp(QuotedRamp.fromJson(__quotedRampJson)); + JsonObject __quotedRampObj = JsonUtil.getJsonObject(jsonObj, "quoted_ramp"); + if (__quotedRampObj != null) { + builder.quotedRamp(QuotedRamp.fromJson(__quotedRampObj)); } - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - builder.customer(Customer.fromJson(__customerJson)); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + builder.customer(Customer.fromJson(__customerObj)); } - String __subscriptionJson = JsonUtil.getObject(json, "subscription"); - if (__subscriptionJson != null) { - builder.subscription(Subscription.fromJson(__subscriptionJson)); + JsonObject __subscriptionObj = JsonUtil.getJsonObject(jsonObj, "subscription"); + if (__subscriptionObj != null) { + builder.subscription(Subscription.fromJson(__subscriptionObj)); } - String __invoiceJson = JsonUtil.getObject(json, "invoice"); - if (__invoiceJson != null) { - builder.invoice(Invoice.fromJson(__invoiceJson)); + JsonObject __invoiceObj = JsonUtil.getJsonObject(jsonObj, "invoice"); + if (__invoiceObj != null) { + builder.invoice(Invoice.fromJson(__invoiceObj)); } - String __creditNoteJson = JsonUtil.getObject(json, "credit_note"); - if (__creditNoteJson != null) { - builder.creditNote(CreditNote.fromJson(__creditNoteJson)); + JsonObject __creditNoteObj = JsonUtil.getJsonObject(jsonObj, "credit_note"); + if (__creditNoteObj != null) { + builder.creditNote(CreditNote.fromJson(__creditNoteObj)); } builder.unbilledCharges( - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "unbilled_charges")).stream() - .map(UnbilledCharge::fromJson) - .collect(java.util.stream.Collectors.toList())); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "unbilled_charges"), UnbilledCharge::fromJson)); builder.httpResponse(httpResponse); return builder.build(); diff --git a/src/main/java/com/chargebee/v4/models/quote/responses/QuoteCreateForChargeItemsAndChargesResponse.java b/src/main/java/com/chargebee/v4/models/quote/responses/QuoteCreateForChargeItemsAndChargesResponse.java index fdeb27a8..575bc358 100644 --- a/src/main/java/com/chargebee/v4/models/quote/responses/QuoteCreateForChargeItemsAndChargesResponse.java +++ b/src/main/java/com/chargebee/v4/models/quote/responses/QuoteCreateForChargeItemsAndChargesResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -36,16 +37,17 @@ public static QuoteCreateForChargeItemsAndChargesResponse fromJson(String json) public static QuoteCreateForChargeItemsAndChargesResponse fromJson( String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __quoteJson = JsonUtil.getObject(json, "quote"); - if (__quoteJson != null) { - builder.quote(Quote.fromJson(__quoteJson)); + JsonObject __quoteObj = JsonUtil.getJsonObject(jsonObj, "quote"); + if (__quoteObj != null) { + builder.quote(Quote.fromJson(__quoteObj)); } - String __quotedChargeJson = JsonUtil.getObject(json, "quoted_charge"); - if (__quotedChargeJson != null) { - builder.quotedCharge(QuotedCharge.fromJson(__quotedChargeJson)); + JsonObject __quotedChargeObj = JsonUtil.getJsonObject(jsonObj, "quoted_charge"); + if (__quotedChargeObj != null) { + builder.quotedCharge(QuotedCharge.fromJson(__quotedChargeObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/quote/responses/QuoteCreateForOnetimeChargesResponse.java b/src/main/java/com/chargebee/v4/models/quote/responses/QuoteCreateForOnetimeChargesResponse.java index 7bb14a5c..56ff9eaa 100644 --- a/src/main/java/com/chargebee/v4/models/quote/responses/QuoteCreateForOnetimeChargesResponse.java +++ b/src/main/java/com/chargebee/v4/models/quote/responses/QuoteCreateForOnetimeChargesResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -33,16 +34,17 @@ public static QuoteCreateForOnetimeChargesResponse fromJson(String json) { /** Parse JSON response into QuoteCreateForOnetimeChargesResponse object with HTTP response. */ public static QuoteCreateForOnetimeChargesResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __quoteJson = JsonUtil.getObject(json, "quote"); - if (__quoteJson != null) { - builder.quote(Quote.fromJson(__quoteJson)); + JsonObject __quoteObj = JsonUtil.getJsonObject(jsonObj, "quote"); + if (__quoteObj != null) { + builder.quote(Quote.fromJson(__quoteObj)); } - String __quotedChargeJson = JsonUtil.getObject(json, "quoted_charge"); - if (__quotedChargeJson != null) { - builder.quotedCharge(QuotedCharge.fromJson(__quotedChargeJson)); + JsonObject __quotedChargeObj = JsonUtil.getJsonObject(jsonObj, "quoted_charge"); + if (__quotedChargeObj != null) { + builder.quotedCharge(QuotedCharge.fromJson(__quotedChargeObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/quote/responses/QuoteDeleteResponse.java b/src/main/java/com/chargebee/v4/models/quote/responses/QuoteDeleteResponse.java index 56d23e7a..ebb1c5dc 100644 --- a/src/main/java/com/chargebee/v4/models/quote/responses/QuoteDeleteResponse.java +++ b/src/main/java/com/chargebee/v4/models/quote/responses/QuoteDeleteResponse.java @@ -10,6 +10,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** Immutable response object for QuoteDelete operation. Contains the response data from the API. */ @@ -42,26 +43,27 @@ public static QuoteDeleteResponse fromJson(String json) { /** Parse JSON response into QuoteDeleteResponse object with HTTP response. */ public static QuoteDeleteResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __quoteJson = JsonUtil.getObject(json, "quote"); - if (__quoteJson != null) { - builder.quote(Quote.fromJson(__quoteJson)); + JsonObject __quoteObj = JsonUtil.getJsonObject(jsonObj, "quote"); + if (__quoteObj != null) { + builder.quote(Quote.fromJson(__quoteObj)); } - String __quotedSubscriptionJson = JsonUtil.getObject(json, "quoted_subscription"); - if (__quotedSubscriptionJson != null) { - builder.quotedSubscription(QuotedSubscription.fromJson(__quotedSubscriptionJson)); + JsonObject __quotedSubscriptionObj = JsonUtil.getJsonObject(jsonObj, "quoted_subscription"); + if (__quotedSubscriptionObj != null) { + builder.quotedSubscription(QuotedSubscription.fromJson(__quotedSubscriptionObj)); } - String __quotedChargeJson = JsonUtil.getObject(json, "quoted_charge"); - if (__quotedChargeJson != null) { - builder.quotedCharge(QuotedCharge.fromJson(__quotedChargeJson)); + JsonObject __quotedChargeObj = JsonUtil.getJsonObject(jsonObj, "quoted_charge"); + if (__quotedChargeObj != null) { + builder.quotedCharge(QuotedCharge.fromJson(__quotedChargeObj)); } - String __quotedRampJson = JsonUtil.getObject(json, "quoted_ramp"); - if (__quotedRampJson != null) { - builder.quotedRamp(QuotedRamp.fromJson(__quotedRampJson)); + JsonObject __quotedRampObj = JsonUtil.getJsonObject(jsonObj, "quoted_ramp"); + if (__quotedRampObj != null) { + builder.quotedRamp(QuotedRamp.fromJson(__quotedRampObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/quote/responses/QuoteEditForChargeItemsAndChargesResponse.java b/src/main/java/com/chargebee/v4/models/quote/responses/QuoteEditForChargeItemsAndChargesResponse.java index 4120ca85..e08cef96 100644 --- a/src/main/java/com/chargebee/v4/models/quote/responses/QuoteEditForChargeItemsAndChargesResponse.java +++ b/src/main/java/com/chargebee/v4/models/quote/responses/QuoteEditForChargeItemsAndChargesResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -36,16 +37,17 @@ public static QuoteEditForChargeItemsAndChargesResponse fromJson(String json) { public static QuoteEditForChargeItemsAndChargesResponse fromJson( String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __quoteJson = JsonUtil.getObject(json, "quote"); - if (__quoteJson != null) { - builder.quote(Quote.fromJson(__quoteJson)); + JsonObject __quoteObj = JsonUtil.getJsonObject(jsonObj, "quote"); + if (__quoteObj != null) { + builder.quote(Quote.fromJson(__quoteObj)); } - String __quotedChargeJson = JsonUtil.getObject(json, "quoted_charge"); - if (__quotedChargeJson != null) { - builder.quotedCharge(QuotedCharge.fromJson(__quotedChargeJson)); + JsonObject __quotedChargeObj = JsonUtil.getJsonObject(jsonObj, "quoted_charge"); + if (__quotedChargeObj != null) { + builder.quotedCharge(QuotedCharge.fromJson(__quotedChargeObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/quote/responses/QuoteExtendExpiryDateResponse.java b/src/main/java/com/chargebee/v4/models/quote/responses/QuoteExtendExpiryDateResponse.java index a6af4128..f1886810 100644 --- a/src/main/java/com/chargebee/v4/models/quote/responses/QuoteExtendExpiryDateResponse.java +++ b/src/main/java/com/chargebee/v4/models/quote/responses/QuoteExtendExpiryDateResponse.java @@ -10,6 +10,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -45,26 +46,27 @@ public static QuoteExtendExpiryDateResponse fromJson(String json) { /** Parse JSON response into QuoteExtendExpiryDateResponse object with HTTP response. */ public static QuoteExtendExpiryDateResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __quoteJson = JsonUtil.getObject(json, "quote"); - if (__quoteJson != null) { - builder.quote(Quote.fromJson(__quoteJson)); + JsonObject __quoteObj = JsonUtil.getJsonObject(jsonObj, "quote"); + if (__quoteObj != null) { + builder.quote(Quote.fromJson(__quoteObj)); } - String __quotedSubscriptionJson = JsonUtil.getObject(json, "quoted_subscription"); - if (__quotedSubscriptionJson != null) { - builder.quotedSubscription(QuotedSubscription.fromJson(__quotedSubscriptionJson)); + JsonObject __quotedSubscriptionObj = JsonUtil.getJsonObject(jsonObj, "quoted_subscription"); + if (__quotedSubscriptionObj != null) { + builder.quotedSubscription(QuotedSubscription.fromJson(__quotedSubscriptionObj)); } - String __quotedChargeJson = JsonUtil.getObject(json, "quoted_charge"); - if (__quotedChargeJson != null) { - builder.quotedCharge(QuotedCharge.fromJson(__quotedChargeJson)); + JsonObject __quotedChargeObj = JsonUtil.getJsonObject(jsonObj, "quoted_charge"); + if (__quotedChargeObj != null) { + builder.quotedCharge(QuotedCharge.fromJson(__quotedChargeObj)); } - String __quotedRampJson = JsonUtil.getObject(json, "quoted_ramp"); - if (__quotedRampJson != null) { - builder.quotedRamp(QuotedRamp.fromJson(__quotedRampJson)); + JsonObject __quotedRampObj = JsonUtil.getJsonObject(jsonObj, "quoted_ramp"); + if (__quotedRampObj != null) { + builder.quotedRamp(QuotedRamp.fromJson(__quotedRampObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/quote/responses/QuoteLineGroupsForQuoteResponse.java b/src/main/java/com/chargebee/v4/models/quote/responses/QuoteLineGroupsForQuoteResponse.java index c28a14a9..50aba9c5 100644 --- a/src/main/java/com/chargebee/v4/models/quote/responses/QuoteLineGroupsForQuoteResponse.java +++ b/src/main/java/com/chargebee/v4/models/quote/responses/QuoteLineGroupsForQuoteResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.exceptions.ChargebeeException; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; import com.chargebee.v4.services.QuoteService; import com.chargebee.v4.models.quote.params.QuoteLineGroupsForQuoteParams; @@ -50,13 +51,13 @@ private QuoteLineGroupsForQuoteResponse( */ public static QuoteLineGroupsForQuoteResponse fromJson(String json) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(QuoteQuoteLineGroupsForQuoteItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "list"), QuoteQuoteLineGroupsForQuoteItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new QuoteLineGroupsForQuoteResponse(list, nextOffset, null, null, null, null); } catch (Exception e) { @@ -75,13 +76,13 @@ public static QuoteLineGroupsForQuoteResponse fromJson( String quoteId, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(QuoteQuoteLineGroupsForQuoteItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "list"), QuoteQuoteLineGroupsForQuoteItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new QuoteLineGroupsForQuoteResponse( list, nextOffset, quoteId, service, originalParams, httpResponse); @@ -184,11 +185,15 @@ public QuoteLineGroup getQuoteLineGroup() { } public static QuoteQuoteLineGroupsForQuoteItem fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static QuoteQuoteLineGroupsForQuoteItem fromJson(JsonObject jsonObj) { QuoteQuoteLineGroupsForQuoteItem item = new QuoteQuoteLineGroupsForQuoteItem(); - String __quoteLineGroupJson = JsonUtil.getObject(json, "quote_line_group"); - if (__quoteLineGroupJson != null) { - item.quoteLineGroup = QuoteLineGroup.fromJson(__quoteLineGroupJson); + JsonObject __quoteLineGroupObj = JsonUtil.getJsonObject(jsonObj, "quote_line_group"); + if (__quoteLineGroupObj != null) { + item.quoteLineGroup = QuoteLineGroup.fromJson(__quoteLineGroupObj); } return item; diff --git a/src/main/java/com/chargebee/v4/models/quote/responses/QuoteListResponse.java b/src/main/java/com/chargebee/v4/models/quote/responses/QuoteListResponse.java index fab66983..7ecae671 100644 --- a/src/main/java/com/chargebee/v4/models/quote/responses/QuoteListResponse.java +++ b/src/main/java/com/chargebee/v4/models/quote/responses/QuoteListResponse.java @@ -10,6 +10,7 @@ import com.chargebee.v4.exceptions.ChargebeeException; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; import com.chargebee.v4.services.QuoteService; import com.chargebee.v4.models.quote.params.QuoteListParams; @@ -47,13 +48,12 @@ private QuoteListResponse( */ public static QuoteListResponse fromJson(String json) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(QuoteListItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "list"), QuoteListItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new QuoteListResponse(list, nextOffset, null, null, null); } catch (Exception e) { @@ -68,13 +68,12 @@ public static QuoteListResponse fromJson(String json) { public static QuoteListResponse fromJson( String json, QuoteService service, QuoteListParams originalParams, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(QuoteListItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "list"), QuoteListItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new QuoteListResponse(list, nextOffset, service, originalParams, httpResponse); } catch (Exception e) { @@ -186,21 +185,25 @@ public QuotedRamp getQuotedRamp() { } public static QuoteListItem fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static QuoteListItem fromJson(JsonObject jsonObj) { QuoteListItem item = new QuoteListItem(); - String __quoteJson = JsonUtil.getObject(json, "quote"); - if (__quoteJson != null) { - item.quote = Quote.fromJson(__quoteJson); + JsonObject __quoteObj = JsonUtil.getJsonObject(jsonObj, "quote"); + if (__quoteObj != null) { + item.quote = Quote.fromJson(__quoteObj); } - String __quotedSubscriptionJson = JsonUtil.getObject(json, "quoted_subscription"); - if (__quotedSubscriptionJson != null) { - item.quotedSubscription = QuotedSubscription.fromJson(__quotedSubscriptionJson); + JsonObject __quotedSubscriptionObj = JsonUtil.getJsonObject(jsonObj, "quoted_subscription"); + if (__quotedSubscriptionObj != null) { + item.quotedSubscription = QuotedSubscription.fromJson(__quotedSubscriptionObj); } - String __quotedRampJson = JsonUtil.getObject(json, "quoted_ramp"); - if (__quotedRampJson != null) { - item.quotedRamp = QuotedRamp.fromJson(__quotedRampJson); + JsonObject __quotedRampObj = JsonUtil.getJsonObject(jsonObj, "quoted_ramp"); + if (__quotedRampObj != null) { + item.quotedRamp = QuotedRamp.fromJson(__quotedRampObj); } return item; diff --git a/src/main/java/com/chargebee/v4/models/quote/responses/QuotePdfResponse.java b/src/main/java/com/chargebee/v4/models/quote/responses/QuotePdfResponse.java index 85059643..a9a0bc1b 100644 --- a/src/main/java/com/chargebee/v4/models/quote/responses/QuotePdfResponse.java +++ b/src/main/java/com/chargebee/v4/models/quote/responses/QuotePdfResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** Immutable response object for QuotePdf operation. Contains the response data from the API. */ @@ -24,11 +25,12 @@ public static QuotePdfResponse fromJson(String json) { /** Parse JSON response into QuotePdfResponse object with HTTP response. */ public static QuotePdfResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __downloadJson = JsonUtil.getObject(json, "download"); - if (__downloadJson != null) { - builder.download(Download.fromJson(__downloadJson)); + JsonObject __downloadObj = JsonUtil.getJsonObject(jsonObj, "download"); + if (__downloadObj != null) { + builder.download(Download.fromJson(__downloadObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/quote/responses/QuoteRetrieveResponse.java b/src/main/java/com/chargebee/v4/models/quote/responses/QuoteRetrieveResponse.java index 4a0531b0..5c4f4b64 100644 --- a/src/main/java/com/chargebee/v4/models/quote/responses/QuoteRetrieveResponse.java +++ b/src/main/java/com/chargebee/v4/models/quote/responses/QuoteRetrieveResponse.java @@ -10,6 +10,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -45,26 +46,27 @@ public static QuoteRetrieveResponse fromJson(String json) { /** Parse JSON response into QuoteRetrieveResponse object with HTTP response. */ public static QuoteRetrieveResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __quoteJson = JsonUtil.getObject(json, "quote"); - if (__quoteJson != null) { - builder.quote(Quote.fromJson(__quoteJson)); + JsonObject __quoteObj = JsonUtil.getJsonObject(jsonObj, "quote"); + if (__quoteObj != null) { + builder.quote(Quote.fromJson(__quoteObj)); } - String __quotedSubscriptionJson = JsonUtil.getObject(json, "quoted_subscription"); - if (__quotedSubscriptionJson != null) { - builder.quotedSubscription(QuotedSubscription.fromJson(__quotedSubscriptionJson)); + JsonObject __quotedSubscriptionObj = JsonUtil.getJsonObject(jsonObj, "quoted_subscription"); + if (__quotedSubscriptionObj != null) { + builder.quotedSubscription(QuotedSubscription.fromJson(__quotedSubscriptionObj)); } - String __quotedChargeJson = JsonUtil.getObject(json, "quoted_charge"); - if (__quotedChargeJson != null) { - builder.quotedCharge(QuotedCharge.fromJson(__quotedChargeJson)); + JsonObject __quotedChargeObj = JsonUtil.getJsonObject(jsonObj, "quoted_charge"); + if (__quotedChargeObj != null) { + builder.quotedCharge(QuotedCharge.fromJson(__quotedChargeObj)); } - String __quotedRampJson = JsonUtil.getObject(json, "quoted_ramp"); - if (__quotedRampJson != null) { - builder.quotedRamp(QuotedRamp.fromJson(__quotedRampJson)); + JsonObject __quotedRampObj = JsonUtil.getJsonObject(jsonObj, "quoted_ramp"); + if (__quotedRampObj != null) { + builder.quotedRamp(QuotedRamp.fromJson(__quotedRampObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/quote/responses/QuoteUpdateStatusResponse.java b/src/main/java/com/chargebee/v4/models/quote/responses/QuoteUpdateStatusResponse.java index 4651e0b5..b4aca95a 100644 --- a/src/main/java/com/chargebee/v4/models/quote/responses/QuoteUpdateStatusResponse.java +++ b/src/main/java/com/chargebee/v4/models/quote/responses/QuoteUpdateStatusResponse.java @@ -10,6 +10,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -45,26 +46,27 @@ public static QuoteUpdateStatusResponse fromJson(String json) { /** Parse JSON response into QuoteUpdateStatusResponse object with HTTP response. */ public static QuoteUpdateStatusResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __quoteJson = JsonUtil.getObject(json, "quote"); - if (__quoteJson != null) { - builder.quote(Quote.fromJson(__quoteJson)); + JsonObject __quoteObj = JsonUtil.getJsonObject(jsonObj, "quote"); + if (__quoteObj != null) { + builder.quote(Quote.fromJson(__quoteObj)); } - String __quotedSubscriptionJson = JsonUtil.getObject(json, "quoted_subscription"); - if (__quotedSubscriptionJson != null) { - builder.quotedSubscription(QuotedSubscription.fromJson(__quotedSubscriptionJson)); + JsonObject __quotedSubscriptionObj = JsonUtil.getJsonObject(jsonObj, "quoted_subscription"); + if (__quotedSubscriptionObj != null) { + builder.quotedSubscription(QuotedSubscription.fromJson(__quotedSubscriptionObj)); } - String __quotedChargeJson = JsonUtil.getObject(json, "quoted_charge"); - if (__quotedChargeJson != null) { - builder.quotedCharge(QuotedCharge.fromJson(__quotedChargeJson)); + JsonObject __quotedChargeObj = JsonUtil.getJsonObject(jsonObj, "quoted_charge"); + if (__quotedChargeObj != null) { + builder.quotedCharge(QuotedCharge.fromJson(__quotedChargeObj)); } - String __quotedRampJson = JsonUtil.getObject(json, "quoted_ramp"); - if (__quotedRampJson != null) { - builder.quotedRamp(QuotedRamp.fromJson(__quotedRampJson)); + JsonObject __quotedRampObj = JsonUtil.getJsonObject(jsonObj, "quoted_ramp"); + if (__quotedRampObj != null) { + builder.quotedRamp(QuotedRamp.fromJson(__quotedRampObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/quote/responses/UpdateSubscriptionQuoteForItemsResponse.java b/src/main/java/com/chargebee/v4/models/quote/responses/UpdateSubscriptionQuoteForItemsResponse.java index 4a4ce7d6..270337d6 100644 --- a/src/main/java/com/chargebee/v4/models/quote/responses/UpdateSubscriptionQuoteForItemsResponse.java +++ b/src/main/java/com/chargebee/v4/models/quote/responses/UpdateSubscriptionQuoteForItemsResponse.java @@ -8,6 +8,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -40,21 +41,22 @@ public static UpdateSubscriptionQuoteForItemsResponse fromJson(String json) { public static UpdateSubscriptionQuoteForItemsResponse fromJson( String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __quoteJson = JsonUtil.getObject(json, "quote"); - if (__quoteJson != null) { - builder.quote(Quote.fromJson(__quoteJson)); + JsonObject __quoteObj = JsonUtil.getJsonObject(jsonObj, "quote"); + if (__quoteObj != null) { + builder.quote(Quote.fromJson(__quoteObj)); } - String __quotedSubscriptionJson = JsonUtil.getObject(json, "quoted_subscription"); - if (__quotedSubscriptionJson != null) { - builder.quotedSubscription(QuotedSubscription.fromJson(__quotedSubscriptionJson)); + JsonObject __quotedSubscriptionObj = JsonUtil.getJsonObject(jsonObj, "quoted_subscription"); + if (__quotedSubscriptionObj != null) { + builder.quotedSubscription(QuotedSubscription.fromJson(__quotedSubscriptionObj)); } - String __quotedRampJson = JsonUtil.getObject(json, "quoted_ramp"); - if (__quotedRampJson != null) { - builder.quotedRamp(QuotedRamp.fromJson(__quotedRampJson)); + JsonObject __quotedRampObj = JsonUtil.getJsonObject(jsonObj, "quoted_ramp"); + if (__quotedRampObj != null) { + builder.quotedRamp(QuotedRamp.fromJson(__quotedRampObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/quote/responses/UpdateSubscriptionQuoteResponse.java b/src/main/java/com/chargebee/v4/models/quote/responses/UpdateSubscriptionQuoteResponse.java index 9db5da1c..ef9e02c8 100644 --- a/src/main/java/com/chargebee/v4/models/quote/responses/UpdateSubscriptionQuoteResponse.java +++ b/src/main/java/com/chargebee/v4/models/quote/responses/UpdateSubscriptionQuoteResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -33,16 +34,17 @@ public static UpdateSubscriptionQuoteResponse fromJson(String json) { /** Parse JSON response into UpdateSubscriptionQuoteResponse object with HTTP response. */ public static UpdateSubscriptionQuoteResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __quoteJson = JsonUtil.getObject(json, "quote"); - if (__quoteJson != null) { - builder.quote(Quote.fromJson(__quoteJson)); + JsonObject __quoteObj = JsonUtil.getJsonObject(jsonObj, "quote"); + if (__quoteObj != null) { + builder.quote(Quote.fromJson(__quoteObj)); } - String __quotedSubscriptionJson = JsonUtil.getObject(json, "quoted_subscription"); - if (__quotedSubscriptionJson != null) { - builder.quotedSubscription(QuotedSubscription.fromJson(__quotedSubscriptionJson)); + JsonObject __quotedSubscriptionObj = JsonUtil.getJsonObject(jsonObj, "quoted_subscription"); + if (__quotedSubscriptionObj != null) { + builder.quotedSubscription(QuotedSubscription.fromJson(__quotedSubscriptionObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/quoteLineGroup/QuoteLineGroup.java b/src/main/java/com/chargebee/v4/models/quoteLineGroup/QuoteLineGroup.java index 404174f7..9cbcba3c 100644 --- a/src/main/java/com/chargebee/v4/models/quoteLineGroup/QuoteLineGroup.java +++ b/src/main/java/com/chargebee/v4/models/quoteLineGroup/QuoteLineGroup.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.quoteLineGroup; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import java.math.BigDecimal; import java.sql.Timestamp; import java.util.List; @@ -122,50 +123,45 @@ public static ChargeEvent fromString(String value) { } public static QuoteLineGroup fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static QuoteLineGroup fromJson(JsonObject jsonObj) { QuoteLineGroup obj = new QuoteLineGroup(); - obj.version = JsonUtil.getInteger(json, "version"); + obj.version = JsonUtil.getInteger(jsonObj, "version"); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.subTotal = JsonUtil.getLong(json, "sub_total"); + obj.subTotal = JsonUtil.getLong(jsonObj, "sub_total"); - obj.total = JsonUtil.getLong(json, "total"); + obj.total = JsonUtil.getLong(jsonObj, "total"); - obj.creditsApplied = JsonUtil.getLong(json, "credits_applied"); + obj.creditsApplied = JsonUtil.getLong(jsonObj, "credits_applied"); - obj.amountPaid = JsonUtil.getLong(json, "amount_paid"); + obj.amountPaid = JsonUtil.getLong(jsonObj, "amount_paid"); - obj.amountDue = JsonUtil.getLong(json, "amount_due"); + obj.amountDue = JsonUtil.getLong(jsonObj, "amount_due"); - obj.chargeEvent = ChargeEvent.fromString(JsonUtil.getString(json, "charge_event")); + obj.chargeEvent = ChargeEvent.fromString(JsonUtil.getString(jsonObj, "charge_event")); - obj.billingCycleNumber = JsonUtil.getInteger(json, "billing_cycle_number"); + obj.billingCycleNumber = JsonUtil.getInteger(jsonObj, "billing_cycle_number"); obj.lineItems = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "line_items")).stream() - .map(LineItems::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "line_items"), LineItems::fromJson); obj.lineItemDiscounts = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "line_item_discounts")).stream() - .map(LineItemDiscounts::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "line_item_discounts"), LineItemDiscounts::fromJson); obj.lineItemTaxes = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "line_item_taxes")).stream() - .map(LineItemTaxes::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "line_item_taxes"), LineItemTaxes::fromJson); obj.discounts = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "discounts")).stream() - .map(Discounts::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "discounts"), Discounts::fromJson); - obj.taxes = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "taxes")).stream() - .map(Taxes::fromJson) - .collect(java.util.stream.Collectors.toList()); + obj.taxes = JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "taxes"), Taxes::fromJson); return obj; } @@ -491,58 +487,62 @@ public static TaxExemptReason fromString(String value) { } public static LineItems fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static LineItems fromJson(JsonObject jsonObj) { LineItems obj = new LineItems(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.subscriptionId = JsonUtil.getString(json, "subscription_id"); + obj.subscriptionId = JsonUtil.getString(jsonObj, "subscription_id"); - obj.dateFrom = JsonUtil.getTimestamp(json, "date_from"); + obj.dateFrom = JsonUtil.getTimestamp(jsonObj, "date_from"); - obj.dateTo = JsonUtil.getTimestamp(json, "date_to"); + obj.dateTo = JsonUtil.getTimestamp(jsonObj, "date_to"); - obj.unitAmount = JsonUtil.getLong(json, "unit_amount"); + obj.unitAmount = JsonUtil.getLong(jsonObj, "unit_amount"); - obj.quantity = JsonUtil.getInteger(json, "quantity"); + obj.quantity = JsonUtil.getInteger(jsonObj, "quantity"); - obj.amount = JsonUtil.getLong(json, "amount"); + obj.amount = JsonUtil.getLong(jsonObj, "amount"); - obj.pricingModel = PricingModel.fromString(JsonUtil.getString(json, "pricing_model")); + obj.pricingModel = PricingModel.fromString(JsonUtil.getString(jsonObj, "pricing_model")); - obj.isTaxed = JsonUtil.getBoolean(json, "is_taxed"); + obj.isTaxed = JsonUtil.getBoolean(jsonObj, "is_taxed"); - obj.taxAmount = JsonUtil.getLong(json, "tax_amount"); + obj.taxAmount = JsonUtil.getLong(jsonObj, "tax_amount"); - obj.taxRate = JsonUtil.getDouble(json, "tax_rate"); + obj.taxRate = JsonUtil.getDouble(jsonObj, "tax_rate"); - obj.unitAmountInDecimal = JsonUtil.getString(json, "unit_amount_in_decimal"); + obj.unitAmountInDecimal = JsonUtil.getString(jsonObj, "unit_amount_in_decimal"); - obj.quantityInDecimal = JsonUtil.getString(json, "quantity_in_decimal"); + obj.quantityInDecimal = JsonUtil.getString(jsonObj, "quantity_in_decimal"); - obj.amountInDecimal = JsonUtil.getString(json, "amount_in_decimal"); + obj.amountInDecimal = JsonUtil.getString(jsonObj, "amount_in_decimal"); - obj.discountAmount = JsonUtil.getLong(json, "discount_amount"); + obj.discountAmount = JsonUtil.getLong(jsonObj, "discount_amount"); - obj.itemLevelDiscountAmount = JsonUtil.getLong(json, "item_level_discount_amount"); + obj.itemLevelDiscountAmount = JsonUtil.getLong(jsonObj, "item_level_discount_amount"); - obj.metered = JsonUtil.getBoolean(json, "metered"); + obj.metered = JsonUtil.getBoolean(jsonObj, "metered"); - obj.isPercentagePricing = JsonUtil.getBoolean(json, "is_percentage_pricing"); + obj.isPercentagePricing = JsonUtil.getBoolean(jsonObj, "is_percentage_pricing"); - obj.referenceLineItemId = JsonUtil.getString(json, "reference_line_item_id"); + obj.referenceLineItemId = JsonUtil.getString(jsonObj, "reference_line_item_id"); - obj.description = JsonUtil.getString(json, "description"); + obj.description = JsonUtil.getString(jsonObj, "description"); - obj.entityDescription = JsonUtil.getString(json, "entity_description"); + obj.entityDescription = JsonUtil.getString(jsonObj, "entity_description"); - obj.entityType = EntityType.fromString(JsonUtil.getString(json, "entity_type")); + obj.entityType = EntityType.fromString(JsonUtil.getString(jsonObj, "entity_type")); obj.taxExemptReason = - TaxExemptReason.fromString(JsonUtil.getString(json, "tax_exempt_reason")); + TaxExemptReason.fromString(JsonUtil.getString(jsonObj, "tax_exempt_reason")); - obj.entityId = JsonUtil.getString(json, "entity_id"); + obj.entityId = JsonUtil.getString(jsonObj, "entity_id"); - obj.customerId = JsonUtil.getString(json, "customer_id"); + obj.customerId = JsonUtil.getString(jsonObj, "customer_id"); return obj; } @@ -733,17 +733,21 @@ public static DiscountType fromString(String value) { } public static LineItemDiscounts fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static LineItemDiscounts fromJson(JsonObject jsonObj) { LineItemDiscounts obj = new LineItemDiscounts(); - obj.lineItemId = JsonUtil.getString(json, "line_item_id"); + obj.lineItemId = JsonUtil.getString(jsonObj, "line_item_id"); - obj.discountType = DiscountType.fromString(JsonUtil.getString(json, "discount_type")); + obj.discountType = DiscountType.fromString(JsonUtil.getString(jsonObj, "discount_type")); - obj.couponId = JsonUtil.getString(json, "coupon_id"); + obj.couponId = JsonUtil.getString(jsonObj, "coupon_id"); - obj.entityId = JsonUtil.getString(json, "entity_id"); + obj.entityId = JsonUtil.getString(jsonObj, "entity_id"); - obj.discountAmount = JsonUtil.getLong(json, "discount_amount"); + obj.discountAmount = JsonUtil.getLong(jsonObj, "discount_amount"); return obj; } @@ -903,37 +907,41 @@ public static TaxJurisType fromString(String value) { } public static LineItemTaxes fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static LineItemTaxes fromJson(JsonObject jsonObj) { LineItemTaxes obj = new LineItemTaxes(); - obj.lineItemId = JsonUtil.getString(json, "line_item_id"); + obj.lineItemId = JsonUtil.getString(jsonObj, "line_item_id"); - obj.taxName = JsonUtil.getString(json, "tax_name"); + obj.taxName = JsonUtil.getString(jsonObj, "tax_name"); - obj.taxRate = JsonUtil.getDouble(json, "tax_rate"); + obj.taxRate = JsonUtil.getDouble(jsonObj, "tax_rate"); - obj.dateTo = JsonUtil.getTimestamp(json, "date_to"); + obj.dateTo = JsonUtil.getTimestamp(jsonObj, "date_to"); - obj.dateFrom = JsonUtil.getTimestamp(json, "date_from"); + obj.dateFrom = JsonUtil.getTimestamp(jsonObj, "date_from"); - obj.proratedTaxableAmount = JsonUtil.getBigDecimal(json, "prorated_taxable_amount"); + obj.proratedTaxableAmount = JsonUtil.getBigDecimal(jsonObj, "prorated_taxable_amount"); - obj.isPartialTaxApplied = JsonUtil.getBoolean(json, "is_partial_tax_applied"); + obj.isPartialTaxApplied = JsonUtil.getBoolean(jsonObj, "is_partial_tax_applied"); - obj.isNonComplianceTax = JsonUtil.getBoolean(json, "is_non_compliance_tax"); + obj.isNonComplianceTax = JsonUtil.getBoolean(jsonObj, "is_non_compliance_tax"); - obj.taxableAmount = JsonUtil.getLong(json, "taxable_amount"); + obj.taxableAmount = JsonUtil.getLong(jsonObj, "taxable_amount"); - obj.taxAmount = JsonUtil.getLong(json, "tax_amount"); + obj.taxAmount = JsonUtil.getLong(jsonObj, "tax_amount"); - obj.taxJurisType = TaxJurisType.fromString(JsonUtil.getString(json, "tax_juris_type")); + obj.taxJurisType = TaxJurisType.fromString(JsonUtil.getString(jsonObj, "tax_juris_type")); - obj.taxJurisName = JsonUtil.getString(json, "tax_juris_name"); + obj.taxJurisName = JsonUtil.getString(jsonObj, "tax_juris_name"); - obj.taxJurisCode = JsonUtil.getString(json, "tax_juris_code"); + obj.taxJurisCode = JsonUtil.getString(jsonObj, "tax_juris_code"); - obj.taxAmountInLocalCurrency = JsonUtil.getLong(json, "tax_amount_in_local_currency"); + obj.taxAmountInLocalCurrency = JsonUtil.getLong(jsonObj, "tax_amount_in_local_currency"); - obj.localCurrencyCode = JsonUtil.getString(json, "local_currency_code"); + obj.localCurrencyCode = JsonUtil.getString(jsonObj, "local_currency_code"); return obj; } @@ -1122,21 +1130,25 @@ public static DiscountType fromString(String value) { } public static Discounts fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Discounts fromJson(JsonObject jsonObj) { Discounts obj = new Discounts(); - obj.amount = JsonUtil.getLong(json, "amount"); + obj.amount = JsonUtil.getLong(jsonObj, "amount"); - obj.description = JsonUtil.getString(json, "description"); + obj.description = JsonUtil.getString(jsonObj, "description"); - obj.lineItemId = JsonUtil.getString(json, "line_item_id"); + obj.lineItemId = JsonUtil.getString(jsonObj, "line_item_id"); - obj.entityType = EntityType.fromString(JsonUtil.getString(json, "entity_type")); + obj.entityType = EntityType.fromString(JsonUtil.getString(jsonObj, "entity_type")); - obj.discountType = DiscountType.fromString(JsonUtil.getString(json, "discount_type")); + obj.discountType = DiscountType.fromString(JsonUtil.getString(jsonObj, "discount_type")); - obj.entityId = JsonUtil.getString(json, "entity_id"); + obj.entityId = JsonUtil.getString(jsonObj, "entity_id"); - obj.couponSetCode = JsonUtil.getString(json, "coupon_set_code"); + obj.couponSetCode = JsonUtil.getString(jsonObj, "coupon_set_code"); return obj; } @@ -1203,13 +1215,17 @@ public String getDescription() { } public static Taxes fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Taxes fromJson(JsonObject jsonObj) { Taxes obj = new Taxes(); - obj.name = JsonUtil.getString(json, "name"); + obj.name = JsonUtil.getString(jsonObj, "name"); - obj.amount = JsonUtil.getLong(json, "amount"); + obj.amount = JsonUtil.getLong(jsonObj, "amount"); - obj.description = JsonUtil.getString(json, "description"); + obj.description = JsonUtil.getString(jsonObj, "description"); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/quotedCharge/QuotedCharge.java b/src/main/java/com/chargebee/v4/models/quotedCharge/QuotedCharge.java index cd41c48d..dfae6194 100644 --- a/src/main/java/com/chargebee/v4/models/quotedCharge/QuotedCharge.java +++ b/src/main/java/com/chargebee/v4/models/quotedCharge/QuotedCharge.java @@ -8,6 +8,8 @@ package com.chargebee.v4.models.quotedCharge; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonArray; +import com.google.gson.JsonObject; import java.util.List; public class QuotedCharge { @@ -44,37 +46,28 @@ public List getAddons() { } public static QuotedCharge fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static QuotedCharge fromJson(JsonObject jsonObj) { QuotedCharge obj = new QuotedCharge(); - obj.charges = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "charges")).stream() - .map(Charges::fromJson) - .collect(java.util.stream.Collectors.toList()); + obj.charges = JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "charges"), Charges::fromJson); obj.invoiceItems = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "invoice_items")).stream() - .map(InvoiceItems::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "invoice_items"), InvoiceItems::fromJson); obj.itemTiers = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "item_tiers")).stream() - .map(ItemTiers::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "item_tiers"), ItemTiers::fromJson); - obj.coupons = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "coupons")).stream() - .map(Coupons::fromJson) - .collect(java.util.stream.Collectors.toList()); + obj.coupons = JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "coupons"), Coupons::fromJson); obj.couponApplicabilityMappings = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "coupon_applicability_mappings")).stream() - .map(CouponApplicabilityMappings::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "coupon_applicability_mappings"), + CouponApplicabilityMappings::fromJson); - obj.addons = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "addons")).stream() - .map(Addons::fromJson) - .collect(java.util.stream.Collectors.toList()); + obj.addons = JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "addons"), Addons::fromJson); return obj; } @@ -189,22 +182,26 @@ public static AvalaraSaleType fromString(String value) { } public static Charges fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Charges fromJson(JsonObject jsonObj) { Charges obj = new Charges(); - obj.amount = JsonUtil.getLong(json, "amount"); + obj.amount = JsonUtil.getLong(jsonObj, "amount"); - obj.amountInDecimal = JsonUtil.getString(json, "amount_in_decimal"); + obj.amountInDecimal = JsonUtil.getString(jsonObj, "amount_in_decimal"); - obj.description = JsonUtil.getString(json, "description"); + obj.description = JsonUtil.getString(jsonObj, "description"); - obj.servicePeriodInDays = JsonUtil.getInteger(json, "service_period_in_days"); + obj.servicePeriodInDays = JsonUtil.getInteger(jsonObj, "service_period_in_days"); obj.avalaraSaleType = - AvalaraSaleType.fromString(JsonUtil.getString(json, "avalara_sale_type")); + AvalaraSaleType.fromString(JsonUtil.getString(jsonObj, "avalara_sale_type")); - obj.avalaraTransactionType = JsonUtil.getInteger(json, "avalara_transaction_type"); + obj.avalaraTransactionType = JsonUtil.getInteger(jsonObj, "avalara_transaction_type"); - obj.avalaraServiceType = JsonUtil.getInteger(json, "avalara_service_type"); + obj.avalaraServiceType = JsonUtil.getInteger(jsonObj, "avalara_service_type"); return obj; } @@ -292,19 +289,23 @@ public Integer getServicePeriodDays() { } public static InvoiceItems fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static InvoiceItems fromJson(JsonObject jsonObj) { InvoiceItems obj = new InvoiceItems(); - obj.itemPriceId = JsonUtil.getString(json, "item_price_id"); + obj.itemPriceId = JsonUtil.getString(jsonObj, "item_price_id"); - obj.quantity = JsonUtil.getInteger(json, "quantity"); + obj.quantity = JsonUtil.getInteger(jsonObj, "quantity"); - obj.quantityInDecimal = JsonUtil.getString(json, "quantity_in_decimal"); + obj.quantityInDecimal = JsonUtil.getString(jsonObj, "quantity_in_decimal"); - obj.unitPrice = JsonUtil.getLong(json, "unit_price"); + obj.unitPrice = JsonUtil.getLong(jsonObj, "unit_price"); - obj.unitPriceInDecimal = JsonUtil.getString(json, "unit_price_in_decimal"); + obj.unitPriceInDecimal = JsonUtil.getString(jsonObj, "unit_price_in_decimal"); - obj.servicePeriodDays = JsonUtil.getInteger(json, "service_period_days"); + obj.servicePeriodDays = JsonUtil.getInteger(jsonObj, "service_period_days"); return obj; } @@ -438,27 +439,31 @@ public static PricingType fromString(String value) { } public static ItemTiers fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static ItemTiers fromJson(JsonObject jsonObj) { ItemTiers obj = new ItemTiers(); - obj.itemPriceId = JsonUtil.getString(json, "item_price_id"); + obj.itemPriceId = JsonUtil.getString(jsonObj, "item_price_id"); - obj.startingUnit = JsonUtil.getInteger(json, "starting_unit"); + obj.startingUnit = JsonUtil.getInteger(jsonObj, "starting_unit"); - obj.endingUnit = JsonUtil.getInteger(json, "ending_unit"); + obj.endingUnit = JsonUtil.getInteger(jsonObj, "ending_unit"); - obj.price = JsonUtil.getLong(json, "price"); + obj.price = JsonUtil.getLong(jsonObj, "price"); - obj.startingUnitInDecimal = JsonUtil.getString(json, "starting_unit_in_decimal"); + obj.startingUnitInDecimal = JsonUtil.getString(jsonObj, "starting_unit_in_decimal"); - obj.endingUnitInDecimal = JsonUtil.getString(json, "ending_unit_in_decimal"); + obj.endingUnitInDecimal = JsonUtil.getString(jsonObj, "ending_unit_in_decimal"); - obj.priceInDecimal = JsonUtil.getString(json, "price_in_decimal"); + obj.priceInDecimal = JsonUtil.getString(jsonObj, "price_in_decimal"); - obj.pricingType = PricingType.fromString(JsonUtil.getString(json, "pricing_type")); + obj.pricingType = PricingType.fromString(JsonUtil.getString(jsonObj, "pricing_type")); - obj.packageSize = JsonUtil.getInteger(json, "package_size"); + obj.packageSize = JsonUtil.getInteger(jsonObj, "package_size"); - obj.index = JsonUtil.getInteger(json, "index"); + obj.index = JsonUtil.getInteger(jsonObj, "index"); return obj; } @@ -533,9 +538,13 @@ public String getCouponId() { } public static Coupons fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Coupons fromJson(JsonObject jsonObj) { Coupons obj = new Coupons(); - obj.couponId = JsonUtil.getString(json, "coupon_id"); + obj.couponId = JsonUtil.getString(jsonObj, "coupon_id"); return obj; } @@ -575,12 +584,19 @@ public List getApplicableItemPriceIds() { } public static CouponApplicabilityMappings fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static CouponApplicabilityMappings fromJson(JsonObject jsonObj) { CouponApplicabilityMappings obj = new CouponApplicabilityMappings(); - obj.couponId = JsonUtil.getString(json, "coupon_id"); + obj.couponId = JsonUtil.getString(jsonObj, "coupon_id"); - obj.applicableItemPriceIds = - JsonUtil.parseArrayOfString(JsonUtil.getArray(json, "applicable_item_price_ids")); + JsonArray __applicableItemPriceIdsArr = + JsonUtil.getJsonArray(jsonObj, "applicable_item_price_ids"); + if (__applicableItemPriceIdsArr != null) { + obj.applicableItemPriceIds = JsonUtil.parseArrayOfString(__applicableItemPriceIdsArr); + } return obj; } @@ -681,21 +697,25 @@ public static ProrationType fromString(String value) { } public static Addons fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Addons fromJson(JsonObject jsonObj) { Addons obj = new Addons(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.quantity = JsonUtil.getInteger(json, "quantity"); + obj.quantity = JsonUtil.getInteger(jsonObj, "quantity"); - obj.unitPrice = JsonUtil.getLong(json, "unit_price"); + obj.unitPrice = JsonUtil.getLong(jsonObj, "unit_price"); - obj.quantityInDecimal = JsonUtil.getString(json, "quantity_in_decimal"); + obj.quantityInDecimal = JsonUtil.getString(jsonObj, "quantity_in_decimal"); - obj.unitPriceInDecimal = JsonUtil.getString(json, "unit_price_in_decimal"); + obj.unitPriceInDecimal = JsonUtil.getString(jsonObj, "unit_price_in_decimal"); - obj.prorationType = ProrationType.fromString(JsonUtil.getString(json, "proration_type")); + obj.prorationType = ProrationType.fromString(JsonUtil.getString(jsonObj, "proration_type")); - obj.servicePeriod = JsonUtil.getInteger(json, "service_period"); + obj.servicePeriod = JsonUtil.getInteger(jsonObj, "service_period"); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/quotedDeltaRamp/QuotedDeltaRamp.java b/src/main/java/com/chargebee/v4/models/quotedDeltaRamp/QuotedDeltaRamp.java index 93f1e28d..a949930f 100644 --- a/src/main/java/com/chargebee/v4/models/quotedDeltaRamp/QuotedDeltaRamp.java +++ b/src/main/java/com/chargebee/v4/models/quotedDeltaRamp/QuotedDeltaRamp.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.quotedDeltaRamp; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import java.util.List; public class QuotedDeltaRamp { @@ -19,12 +20,14 @@ public List getLineItems() { } public static QuotedDeltaRamp fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static QuotedDeltaRamp fromJson(JsonObject jsonObj) { QuotedDeltaRamp obj = new QuotedDeltaRamp(); obj.lineItems = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "line_items")).stream() - .map(LineItems::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "line_items"), LineItems::fromJson); return obj; } @@ -58,10 +61,14 @@ public String getItemLevelDiscountPerBillingCycleInDecimal() { } public static LineItems fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static LineItems fromJson(JsonObject jsonObj) { LineItems obj = new LineItems(); obj.itemLevelDiscountPerBillingCycleInDecimal = - JsonUtil.getString(json, "item_level_discount_per_billing_cycle_in_decimal"); + JsonUtil.getString(jsonObj, "item_level_discount_per_billing_cycle_in_decimal"); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/quotedRamp/QuotedRamp.java b/src/main/java/com/chargebee/v4/models/quotedRamp/QuotedRamp.java index 7588b499..0ea46db0 100644 --- a/src/main/java/com/chargebee/v4/models/quotedRamp/QuotedRamp.java +++ b/src/main/java/com/chargebee/v4/models/quotedRamp/QuotedRamp.java @@ -8,6 +8,8 @@ package com.chargebee.v4.models.quotedRamp; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonArray; +import com.google.gson.JsonObject; import java.sql.Timestamp; import java.util.List; @@ -40,29 +42,27 @@ public List getCouponApplicabilityMappings() { } public static QuotedRamp fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static QuotedRamp fromJson(JsonObject jsonObj) { QuotedRamp obj = new QuotedRamp(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); obj.lineItems = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "line_items")).stream() - .map(LineItems::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "line_items"), LineItems::fromJson); obj.discounts = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "discounts")).stream() - .map(Discounts::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "discounts"), Discounts::fromJson); obj.itemTiers = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "item_tiers")).stream() - .map(ItemTiers::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "item_tiers"), ItemTiers::fromJson); obj.couponApplicabilityMappings = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "coupon_applicability_mappings")).stream() - .map(CouponApplicabilityMappings::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "coupon_applicability_mappings"), + CouponApplicabilityMappings::fromJson); return obj; } @@ -378,71 +378,76 @@ public static ChargeOnOption fromString(String value) { } public static LineItems fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static LineItems fromJson(JsonObject jsonObj) { LineItems obj = new LineItems(); - obj.itemPriceId = JsonUtil.getString(json, "item_price_id"); + obj.itemPriceId = JsonUtil.getString(jsonObj, "item_price_id"); - obj.itemType = ItemType.fromString(JsonUtil.getString(json, "item_type")); + obj.itemType = ItemType.fromString(JsonUtil.getString(jsonObj, "item_type")); - obj.quantity = JsonUtil.getInteger(json, "quantity"); + obj.quantity = JsonUtil.getInteger(jsonObj, "quantity"); - obj.quantityInDecimal = JsonUtil.getString(json, "quantity_in_decimal"); + obj.quantityInDecimal = JsonUtil.getString(jsonObj, "quantity_in_decimal"); - obj.meteredQuantity = JsonUtil.getString(json, "metered_quantity"); + obj.meteredQuantity = JsonUtil.getString(jsonObj, "metered_quantity"); - obj.unitPrice = JsonUtil.getLong(json, "unit_price"); + obj.unitPrice = JsonUtil.getLong(jsonObj, "unit_price"); - obj.unitPriceInDecimal = JsonUtil.getString(json, "unit_price_in_decimal"); + obj.unitPriceInDecimal = JsonUtil.getString(jsonObj, "unit_price_in_decimal"); - obj.amount = JsonUtil.getLong(json, "amount"); + obj.amount = JsonUtil.getLong(jsonObj, "amount"); - obj.amountInDecimal = JsonUtil.getString(json, "amount_in_decimal"); + obj.amountInDecimal = JsonUtil.getString(jsonObj, "amount_in_decimal"); - obj.billingPeriod = JsonUtil.getInteger(json, "billing_period"); + obj.billingPeriod = JsonUtil.getInteger(jsonObj, "billing_period"); obj.billingPeriodUnit = - BillingPeriodUnit.fromString(JsonUtil.getString(json, "billing_period_unit")); + BillingPeriodUnit.fromString(JsonUtil.getString(jsonObj, "billing_period_unit")); - obj.freeQuantity = JsonUtil.getInteger(json, "free_quantity"); + obj.freeQuantity = JsonUtil.getInteger(jsonObj, "free_quantity"); - obj.freeQuantityInDecimal = JsonUtil.getString(json, "free_quantity_in_decimal"); + obj.freeQuantityInDecimal = JsonUtil.getString(jsonObj, "free_quantity_in_decimal"); - obj.billingCycles = JsonUtil.getInteger(json, "billing_cycles"); + obj.billingCycles = JsonUtil.getInteger(jsonObj, "billing_cycles"); - obj.servicePeriodDays = JsonUtil.getInteger(json, "service_period_days"); + obj.servicePeriodDays = JsonUtil.getInteger(jsonObj, "service_period_days"); - obj.chargeOnEvent = ChargeOnEvent.fromString(JsonUtil.getString(json, "charge_on_event")); + obj.chargeOnEvent = ChargeOnEvent.fromString(JsonUtil.getString(jsonObj, "charge_on_event")); - obj.chargeOnce = JsonUtil.getBoolean(json, "charge_once"); + obj.chargeOnce = JsonUtil.getBoolean(jsonObj, "charge_once"); - obj.chargeOnOption = ChargeOnOption.fromString(JsonUtil.getString(json, "charge_on_option")); + obj.chargeOnOption = + ChargeOnOption.fromString(JsonUtil.getString(jsonObj, "charge_on_option")); - obj.startDate = JsonUtil.getTimestamp(json, "start_date"); + obj.startDate = JsonUtil.getTimestamp(jsonObj, "start_date"); - obj.endDate = JsonUtil.getTimestamp(json, "end_date"); + obj.endDate = JsonUtil.getTimestamp(jsonObj, "end_date"); - obj.rampTierId = JsonUtil.getString(json, "ramp_tier_id"); + obj.rampTierId = JsonUtil.getString(jsonObj, "ramp_tier_id"); - obj.discountPerBillingCycle = JsonUtil.getLong(json, "discount_per_billing_cycle"); + obj.discountPerBillingCycle = JsonUtil.getLong(jsonObj, "discount_per_billing_cycle"); obj.discountPerBillingCycleInDecimal = - JsonUtil.getString(json, "discount_per_billing_cycle_in_decimal"); + JsonUtil.getString(jsonObj, "discount_per_billing_cycle_in_decimal"); obj.itemLevelDiscountPerBillingCycle = - JsonUtil.getLong(json, "item_level_discount_per_billing_cycle"); + JsonUtil.getLong(jsonObj, "item_level_discount_per_billing_cycle"); obj.itemLevelDiscountPerBillingCycleInDecimal = - JsonUtil.getString(json, "item_level_discount_per_billing_cycle_in_decimal"); + JsonUtil.getString(jsonObj, "item_level_discount_per_billing_cycle_in_decimal"); - obj.amountPerBillingCycle = JsonUtil.getLong(json, "amount_per_billing_cycle"); + obj.amountPerBillingCycle = JsonUtil.getLong(jsonObj, "amount_per_billing_cycle"); obj.amountPerBillingCycleInDecimal = - JsonUtil.getString(json, "amount_per_billing_cycle_in_decimal"); + JsonUtil.getString(jsonObj, "amount_per_billing_cycle_in_decimal"); - obj.netAmountPerBillingCycle = JsonUtil.getLong(json, "net_amount_per_billing_cycle"); + obj.netAmountPerBillingCycle = JsonUtil.getLong(jsonObj, "net_amount_per_billing_cycle"); obj.netAmountPerBillingCycleInDecimal = - JsonUtil.getString(json, "net_amount_per_billing_cycle_in_decimal"); + JsonUtil.getString(jsonObj, "net_amount_per_billing_cycle_in_decimal"); return obj; } @@ -829,41 +834,45 @@ public static ApplyOn fromString(String value) { } public static Discounts fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Discounts fromJson(JsonObject jsonObj) { Discounts obj = new Discounts(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.invoiceName = JsonUtil.getString(json, "invoice_name"); + obj.invoiceName = JsonUtil.getString(jsonObj, "invoice_name"); - obj.type = Type.fromString(JsonUtil.getString(json, "type")); + obj.type = Type.fromString(JsonUtil.getString(jsonObj, "type")); - obj.percentage = JsonUtil.getDouble(json, "percentage"); + obj.percentage = JsonUtil.getDouble(jsonObj, "percentage"); - obj.amount = JsonUtil.getLong(json, "amount"); + obj.amount = JsonUtil.getLong(jsonObj, "amount"); - obj.durationType = DurationType.fromString(JsonUtil.getString(json, "duration_type")); + obj.durationType = DurationType.fromString(JsonUtil.getString(jsonObj, "duration_type")); - obj.entityType = EntityType.fromString(JsonUtil.getString(json, "entity_type")); + obj.entityType = EntityType.fromString(JsonUtil.getString(jsonObj, "entity_type")); - obj.entityId = JsonUtil.getString(json, "entity_id"); + obj.entityId = JsonUtil.getString(jsonObj, "entity_id"); - obj.period = JsonUtil.getInteger(json, "period"); + obj.period = JsonUtil.getInteger(jsonObj, "period"); - obj.periodUnit = PeriodUnit.fromString(JsonUtil.getString(json, "period_unit")); + obj.periodUnit = PeriodUnit.fromString(JsonUtil.getString(jsonObj, "period_unit")); - obj.includedInMrr = JsonUtil.getBoolean(json, "included_in_mrr"); + obj.includedInMrr = JsonUtil.getBoolean(jsonObj, "included_in_mrr"); - obj.applyOn = ApplyOn.fromString(JsonUtil.getString(json, "apply_on")); + obj.applyOn = ApplyOn.fromString(JsonUtil.getString(jsonObj, "apply_on")); - obj.itemPriceId = JsonUtil.getString(json, "item_price_id"); + obj.itemPriceId = JsonUtil.getString(jsonObj, "item_price_id"); - obj.createdAt = JsonUtil.getTimestamp(json, "created_at"); + obj.createdAt = JsonUtil.getTimestamp(jsonObj, "created_at"); - obj.updatedAt = JsonUtil.getTimestamp(json, "updated_at"); + obj.updatedAt = JsonUtil.getTimestamp(jsonObj, "updated_at"); - obj.startDate = JsonUtil.getTimestamp(json, "start_date"); + obj.startDate = JsonUtil.getTimestamp(jsonObj, "start_date"); - obj.endDate = JsonUtil.getTimestamp(json, "end_date"); + obj.endDate = JsonUtil.getTimestamp(jsonObj, "end_date"); return obj; } @@ -1041,27 +1050,31 @@ public static PricingType fromString(String value) { } public static ItemTiers fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static ItemTiers fromJson(JsonObject jsonObj) { ItemTiers obj = new ItemTiers(); - obj.itemPriceId = JsonUtil.getString(json, "item_price_id"); + obj.itemPriceId = JsonUtil.getString(jsonObj, "item_price_id"); - obj.startingUnit = JsonUtil.getInteger(json, "starting_unit"); + obj.startingUnit = JsonUtil.getInteger(jsonObj, "starting_unit"); - obj.endingUnit = JsonUtil.getInteger(json, "ending_unit"); + obj.endingUnit = JsonUtil.getInteger(jsonObj, "ending_unit"); - obj.price = JsonUtil.getLong(json, "price"); + obj.price = JsonUtil.getLong(jsonObj, "price"); - obj.startingUnitInDecimal = JsonUtil.getString(json, "starting_unit_in_decimal"); + obj.startingUnitInDecimal = JsonUtil.getString(jsonObj, "starting_unit_in_decimal"); - obj.endingUnitInDecimal = JsonUtil.getString(json, "ending_unit_in_decimal"); + obj.endingUnitInDecimal = JsonUtil.getString(jsonObj, "ending_unit_in_decimal"); - obj.priceInDecimal = JsonUtil.getString(json, "price_in_decimal"); + obj.priceInDecimal = JsonUtil.getString(jsonObj, "price_in_decimal"); - obj.rampTierId = JsonUtil.getString(json, "ramp_tier_id"); + obj.rampTierId = JsonUtil.getString(jsonObj, "ramp_tier_id"); - obj.pricingType = PricingType.fromString(JsonUtil.getString(json, "pricing_type")); + obj.pricingType = PricingType.fromString(JsonUtil.getString(jsonObj, "pricing_type")); - obj.packageSize = JsonUtil.getInteger(json, "package_size"); + obj.packageSize = JsonUtil.getInteger(jsonObj, "package_size"); return obj; } @@ -1141,12 +1154,19 @@ public List getApplicableItemPriceIds() { } public static CouponApplicabilityMappings fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static CouponApplicabilityMappings fromJson(JsonObject jsonObj) { CouponApplicabilityMappings obj = new CouponApplicabilityMappings(); - obj.couponId = JsonUtil.getString(json, "coupon_id"); + obj.couponId = JsonUtil.getString(jsonObj, "coupon_id"); - obj.applicableItemPriceIds = - JsonUtil.parseArrayOfString(JsonUtil.getArray(json, "applicable_item_price_ids")); + JsonArray __applicableItemPriceIdsArr = + JsonUtil.getJsonArray(jsonObj, "applicable_item_price_ids"); + if (__applicableItemPriceIdsArr != null) { + obj.applicableItemPriceIds = JsonUtil.parseArrayOfString(__applicableItemPriceIdsArr); + } return obj; } diff --git a/src/main/java/com/chargebee/v4/models/quotedSubscription/QuotedSubscription.java b/src/main/java/com/chargebee/v4/models/quotedSubscription/QuotedSubscription.java index 29db9b9a..b44fd5b3 100644 --- a/src/main/java/com/chargebee/v4/models/quotedSubscription/QuotedSubscription.java +++ b/src/main/java/com/chargebee/v4/models/quotedSubscription/QuotedSubscription.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.quotedSubscription; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import java.sql.Timestamp; import java.util.List; @@ -220,73 +221,67 @@ public static BillingPeriodUnit fromString(String value) { } public static QuotedSubscription fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static QuotedSubscription fromJson(JsonObject jsonObj) { QuotedSubscription obj = new QuotedSubscription(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.startDate = JsonUtil.getTimestamp(json, "start_date"); + obj.startDate = JsonUtil.getTimestamp(jsonObj, "start_date"); - obj.trialEnd = JsonUtil.getTimestamp(json, "trial_end"); + obj.trialEnd = JsonUtil.getTimestamp(jsonObj, "trial_end"); - obj.remainingBillingCycles = JsonUtil.getInteger(json, "remaining_billing_cycles"); + obj.remainingBillingCycles = JsonUtil.getInteger(jsonObj, "remaining_billing_cycles"); - obj.poNumber = JsonUtil.getString(json, "po_number"); + obj.poNumber = JsonUtil.getString(jsonObj, "po_number"); - obj.planQuantityInDecimal = JsonUtil.getString(json, "plan_quantity_in_decimal"); + obj.planQuantityInDecimal = JsonUtil.getString(jsonObj, "plan_quantity_in_decimal"); - obj.planUnitPriceInDecimal = JsonUtil.getString(json, "plan_unit_price_in_decimal"); + obj.planUnitPriceInDecimal = JsonUtil.getString(jsonObj, "plan_unit_price_in_decimal"); - obj.changesScheduledAt = JsonUtil.getTimestamp(json, "changes_scheduled_at"); + obj.changesScheduledAt = JsonUtil.getTimestamp(jsonObj, "changes_scheduled_at"); - obj.changeOption = ChangeOption.fromString(JsonUtil.getString(json, "change_option")); + obj.changeOption = ChangeOption.fromString(JsonUtil.getString(jsonObj, "change_option")); obj.contractTermBillingCycleOnRenewal = - JsonUtil.getInteger(json, "contract_term_billing_cycle_on_renewal"); + JsonUtil.getInteger(jsonObj, "contract_term_billing_cycle_on_renewal"); - obj.coupons = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "coupons")).stream() - .map(Coupons::fromJson) - .collect(java.util.stream.Collectors.toList()); + obj.coupons = JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "coupons"), Coupons::fromJson); obj.subscriptionItems = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "subscription_items")).stream() - .map(SubscriptionItems::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "subscription_items"), SubscriptionItems::fromJson); obj.itemTiers = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "item_tiers")).stream() - .map(ItemTiers::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "item_tiers"), ItemTiers::fromJson); - String __quotedContractTermJson = JsonUtil.getObject(json, "quoted_contract_term"); - if (__quotedContractTermJson != null) { - obj.quotedContractTerm = QuotedContractTerm.fromJson(__quotedContractTermJson); + JsonObject __quotedContractTermObj = JsonUtil.getJsonObject(jsonObj, "quoted_contract_term"); + if (__quotedContractTermObj != null) { + obj.quotedContractTerm = QuotedContractTerm.fromJson(__quotedContractTermObj); } - obj.billingPeriod = JsonUtil.getInteger(json, "billing_period"); + obj.billingPeriod = JsonUtil.getInteger(jsonObj, "billing_period"); - obj.setupFee = JsonUtil.getLong(json, "setup_fee"); + obj.setupFee = JsonUtil.getLong(jsonObj, "setup_fee"); - obj.autoCollection = AutoCollection.fromString(JsonUtil.getString(json, "auto_collection")); + obj.autoCollection = AutoCollection.fromString(JsonUtil.getString(jsonObj, "auto_collection")); obj.eventBasedAddons = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "event_based_addons")).stream() - .map(EventBasedAddons::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "event_based_addons"), EventBasedAddons::fromJson); - obj.addons = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "addons")).stream() - .map(Addons::fromJson) - .collect(java.util.stream.Collectors.toList()); + obj.addons = JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "addons"), Addons::fromJson); obj.billingPeriodUnit = - BillingPeriodUnit.fromString(JsonUtil.getString(json, "billing_period_unit")); + BillingPeriodUnit.fromString(JsonUtil.getString(jsonObj, "billing_period_unit")); - obj.planQuantity = JsonUtil.getInteger(json, "plan_quantity"); + obj.planQuantity = JsonUtil.getInteger(jsonObj, "plan_quantity"); - obj.planId = JsonUtil.getString(json, "plan_id"); + obj.planId = JsonUtil.getString(jsonObj, "plan_id"); - obj.planUnitPrice = JsonUtil.getLong(json, "plan_unit_price"); + obj.planUnitPrice = JsonUtil.getLong(jsonObj, "plan_unit_price"); return obj; } @@ -413,9 +408,13 @@ public String getCouponId() { } public static Coupons fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Coupons fromJson(JsonObject jsonObj) { Coupons obj = new Coupons(); - obj.couponId = JsonUtil.getString(json, "coupon_id"); + obj.couponId = JsonUtil.getString(jsonObj, "coupon_id"); return obj; } @@ -759,60 +758,65 @@ public static UsageAccumulationResetFrequency fromString(String value) { } public static SubscriptionItems fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static SubscriptionItems fromJson(JsonObject jsonObj) { SubscriptionItems obj = new SubscriptionItems(); - obj.itemPriceId = JsonUtil.getString(json, "item_price_id"); + obj.itemPriceId = JsonUtil.getString(jsonObj, "item_price_id"); - obj.itemType = ItemType.fromString(JsonUtil.getString(json, "item_type")); + obj.itemType = ItemType.fromString(JsonUtil.getString(jsonObj, "item_type")); - obj.quantity = JsonUtil.getInteger(json, "quantity"); + obj.quantity = JsonUtil.getInteger(jsonObj, "quantity"); - obj.quantityInDecimal = JsonUtil.getString(json, "quantity_in_decimal"); + obj.quantityInDecimal = JsonUtil.getString(jsonObj, "quantity_in_decimal"); - obj.meteredQuantity = JsonUtil.getString(json, "metered_quantity"); + obj.meteredQuantity = JsonUtil.getString(jsonObj, "metered_quantity"); - obj.lastCalculatedAt = JsonUtil.getTimestamp(json, "last_calculated_at"); + obj.lastCalculatedAt = JsonUtil.getTimestamp(jsonObj, "last_calculated_at"); - obj.unitPrice = JsonUtil.getLong(json, "unit_price"); + obj.unitPrice = JsonUtil.getLong(jsonObj, "unit_price"); - obj.unitPriceInDecimal = JsonUtil.getString(json, "unit_price_in_decimal"); + obj.unitPriceInDecimal = JsonUtil.getString(jsonObj, "unit_price_in_decimal"); - obj.amount = JsonUtil.getLong(json, "amount"); + obj.amount = JsonUtil.getLong(jsonObj, "amount"); - obj.currentTermStart = JsonUtil.getTimestamp(json, "current_term_start"); + obj.currentTermStart = JsonUtil.getTimestamp(jsonObj, "current_term_start"); - obj.currentTermEnd = JsonUtil.getTimestamp(json, "current_term_end"); + obj.currentTermEnd = JsonUtil.getTimestamp(jsonObj, "current_term_end"); - obj.nextBillingAt = JsonUtil.getTimestamp(json, "next_billing_at"); + obj.nextBillingAt = JsonUtil.getTimestamp(jsonObj, "next_billing_at"); - obj.amountInDecimal = JsonUtil.getString(json, "amount_in_decimal"); + obj.amountInDecimal = JsonUtil.getString(jsonObj, "amount_in_decimal"); - obj.billingPeriod = JsonUtil.getInteger(json, "billing_period"); + obj.billingPeriod = JsonUtil.getInteger(jsonObj, "billing_period"); obj.billingPeriodUnit = - BillingPeriodUnit.fromString(JsonUtil.getString(json, "billing_period_unit")); + BillingPeriodUnit.fromString(JsonUtil.getString(jsonObj, "billing_period_unit")); - obj.freeQuantity = JsonUtil.getInteger(json, "free_quantity"); + obj.freeQuantity = JsonUtil.getInteger(jsonObj, "free_quantity"); - obj.freeQuantityInDecimal = JsonUtil.getString(json, "free_quantity_in_decimal"); + obj.freeQuantityInDecimal = JsonUtil.getString(jsonObj, "free_quantity_in_decimal"); - obj.trialEnd = JsonUtil.getTimestamp(json, "trial_end"); + obj.trialEnd = JsonUtil.getTimestamp(jsonObj, "trial_end"); - obj.billingCycles = JsonUtil.getInteger(json, "billing_cycles"); + obj.billingCycles = JsonUtil.getInteger(jsonObj, "billing_cycles"); - obj.servicePeriodDays = JsonUtil.getInteger(json, "service_period_days"); + obj.servicePeriodDays = JsonUtil.getInteger(jsonObj, "service_period_days"); - obj.chargeOnEvent = ChargeOnEvent.fromString(JsonUtil.getString(json, "charge_on_event")); + obj.chargeOnEvent = ChargeOnEvent.fromString(JsonUtil.getString(jsonObj, "charge_on_event")); - obj.chargeOnce = JsonUtil.getBoolean(json, "charge_once"); + obj.chargeOnce = JsonUtil.getBoolean(jsonObj, "charge_once"); - obj.chargeOnOption = ChargeOnOption.fromString(JsonUtil.getString(json, "charge_on_option")); + obj.chargeOnOption = + ChargeOnOption.fromString(JsonUtil.getString(jsonObj, "charge_on_option")); - obj.prorationType = ProrationType.fromString(JsonUtil.getString(json, "proration_type")); + obj.prorationType = ProrationType.fromString(JsonUtil.getString(jsonObj, "proration_type")); obj.usageAccumulationResetFrequency = UsageAccumulationResetFrequency.fromString( - JsonUtil.getString(json, "usage_accumulation_reset_frequency")); + JsonUtil.getString(jsonObj, "usage_accumulation_reset_frequency")); return obj; } @@ -1023,27 +1027,31 @@ public static PricingType fromString(String value) { } public static ItemTiers fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static ItemTiers fromJson(JsonObject jsonObj) { ItemTiers obj = new ItemTiers(); - obj.itemPriceId = JsonUtil.getString(json, "item_price_id"); + obj.itemPriceId = JsonUtil.getString(jsonObj, "item_price_id"); - obj.startingUnit = JsonUtil.getInteger(json, "starting_unit"); + obj.startingUnit = JsonUtil.getInteger(jsonObj, "starting_unit"); - obj.endingUnit = JsonUtil.getInteger(json, "ending_unit"); + obj.endingUnit = JsonUtil.getInteger(jsonObj, "ending_unit"); - obj.price = JsonUtil.getLong(json, "price"); + obj.price = JsonUtil.getLong(jsonObj, "price"); - obj.startingUnitInDecimal = JsonUtil.getString(json, "starting_unit_in_decimal"); + obj.startingUnitInDecimal = JsonUtil.getString(jsonObj, "starting_unit_in_decimal"); - obj.endingUnitInDecimal = JsonUtil.getString(json, "ending_unit_in_decimal"); + obj.endingUnitInDecimal = JsonUtil.getString(jsonObj, "ending_unit_in_decimal"); - obj.priceInDecimal = JsonUtil.getString(json, "price_in_decimal"); + obj.priceInDecimal = JsonUtil.getString(jsonObj, "price_in_decimal"); - obj.pricingType = PricingType.fromString(JsonUtil.getString(json, "pricing_type")); + obj.pricingType = PricingType.fromString(JsonUtil.getString(jsonObj, "pricing_type")); - obj.packageSize = JsonUtil.getInteger(json, "package_size"); + obj.packageSize = JsonUtil.getInteger(jsonObj, "package_size"); - obj.index = JsonUtil.getInteger(json, "index"); + obj.index = JsonUtil.getInteger(jsonObj, "index"); return obj; } @@ -1175,20 +1183,24 @@ public static ActionAtTermEnd fromString(String value) { } public static QuotedContractTerm fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static QuotedContractTerm fromJson(JsonObject jsonObj) { QuotedContractTerm obj = new QuotedContractTerm(); - obj.contractStart = JsonUtil.getTimestamp(json, "contract_start"); + obj.contractStart = JsonUtil.getTimestamp(jsonObj, "contract_start"); - obj.contractEnd = JsonUtil.getTimestamp(json, "contract_end"); + obj.contractEnd = JsonUtil.getTimestamp(jsonObj, "contract_end"); - obj.billingCycle = JsonUtil.getInteger(json, "billing_cycle"); + obj.billingCycle = JsonUtil.getInteger(jsonObj, "billing_cycle"); obj.actionAtTermEnd = - ActionAtTermEnd.fromString(JsonUtil.getString(json, "action_at_term_end")); + ActionAtTermEnd.fromString(JsonUtil.getString(jsonObj, "action_at_term_end")); - obj.totalContractValue = JsonUtil.getLong(json, "total_contract_value"); + obj.totalContractValue = JsonUtil.getLong(jsonObj, "total_contract_value"); - obj.cancellationCutoffPeriod = JsonUtil.getInteger(json, "cancellation_cutoff_period"); + obj.cancellationCutoffPeriod = JsonUtil.getInteger(jsonObj, "cancellation_cutoff_period"); return obj; } @@ -1317,23 +1329,27 @@ public static OnEvent fromString(String value) { } public static EventBasedAddons fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static EventBasedAddons fromJson(JsonObject jsonObj) { EventBasedAddons obj = new EventBasedAddons(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.quantity = JsonUtil.getInteger(json, "quantity"); + obj.quantity = JsonUtil.getInteger(jsonObj, "quantity"); - obj.unitPrice = JsonUtil.getLong(json, "unit_price"); + obj.unitPrice = JsonUtil.getLong(jsonObj, "unit_price"); - obj.servicePeriodInDays = JsonUtil.getInteger(json, "service_period_in_days"); + obj.servicePeriodInDays = JsonUtil.getInteger(jsonObj, "service_period_in_days"); - obj.onEvent = OnEvent.fromString(JsonUtil.getString(json, "on_event")); + obj.onEvent = OnEvent.fromString(JsonUtil.getString(jsonObj, "on_event")); - obj.chargeOnce = JsonUtil.getBoolean(json, "charge_once"); + obj.chargeOnce = JsonUtil.getBoolean(jsonObj, "charge_once"); - obj.quantityInDecimal = JsonUtil.getString(json, "quantity_in_decimal"); + obj.quantityInDecimal = JsonUtil.getString(jsonObj, "quantity_in_decimal"); - obj.unitPriceInDecimal = JsonUtil.getString(json, "unit_price_in_decimal"); + obj.unitPriceInDecimal = JsonUtil.getString(jsonObj, "unit_price_in_decimal"); return obj; } @@ -1475,27 +1491,31 @@ public static ProrationType fromString(String value) { } public static Addons fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Addons fromJson(JsonObject jsonObj) { Addons obj = new Addons(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.quantity = JsonUtil.getInteger(json, "quantity"); + obj.quantity = JsonUtil.getInteger(jsonObj, "quantity"); - obj.unitPrice = JsonUtil.getLong(json, "unit_price"); + obj.unitPrice = JsonUtil.getLong(jsonObj, "unit_price"); - obj.amount = JsonUtil.getLong(json, "amount"); + obj.amount = JsonUtil.getLong(jsonObj, "amount"); - obj.trialEnd = JsonUtil.getTimestamp(json, "trial_end"); + obj.trialEnd = JsonUtil.getTimestamp(jsonObj, "trial_end"); - obj.remainingBillingCycles = JsonUtil.getInteger(json, "remaining_billing_cycles"); + obj.remainingBillingCycles = JsonUtil.getInteger(jsonObj, "remaining_billing_cycles"); - obj.quantityInDecimal = JsonUtil.getString(json, "quantity_in_decimal"); + obj.quantityInDecimal = JsonUtil.getString(jsonObj, "quantity_in_decimal"); - obj.unitPriceInDecimal = JsonUtil.getString(json, "unit_price_in_decimal"); + obj.unitPriceInDecimal = JsonUtil.getString(jsonObj, "unit_price_in_decimal"); - obj.amountInDecimal = JsonUtil.getString(json, "amount_in_decimal"); + obj.amountInDecimal = JsonUtil.getString(jsonObj, "amount_in_decimal"); - obj.prorationType = ProrationType.fromString(JsonUtil.getString(json, "proration_type")); + obj.prorationType = ProrationType.fromString(JsonUtil.getString(jsonObj, "proration_type")); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/ramp/Ramp.java b/src/main/java/com/chargebee/v4/models/ramp/Ramp.java index 92a25ee3..e7e1a5f2 100644 --- a/src/main/java/com/chargebee/v4/models/ramp/Ramp.java +++ b/src/main/java/com/chargebee/v4/models/ramp/Ramp.java @@ -8,6 +8,8 @@ package com.chargebee.v4.models.ramp; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonArray; +import com.google.gson.JsonObject; import java.sql.Timestamp; import java.util.List; @@ -142,66 +144,71 @@ public static Status fromString(String value) { } public static Ramp fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Ramp fromJson(JsonObject jsonObj) { Ramp obj = new Ramp(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.description = JsonUtil.getString(json, "description"); + obj.description = JsonUtil.getString(jsonObj, "description"); - obj.subscriptionId = JsonUtil.getString(json, "subscription_id"); + obj.subscriptionId = JsonUtil.getString(jsonObj, "subscription_id"); - obj.effectiveFrom = JsonUtil.getTimestamp(json, "effective_from"); + obj.effectiveFrom = JsonUtil.getTimestamp(jsonObj, "effective_from"); - obj.status = Status.fromString(JsonUtil.getString(json, "status")); + obj.status = Status.fromString(JsonUtil.getString(jsonObj, "status")); - obj.createdAt = JsonUtil.getTimestamp(json, "created_at"); + obj.createdAt = JsonUtil.getTimestamp(jsonObj, "created_at"); - obj.resourceVersion = JsonUtil.getLong(json, "resource_version"); + obj.resourceVersion = JsonUtil.getLong(jsonObj, "resource_version"); - obj.updatedAt = JsonUtil.getTimestamp(json, "updated_at"); + obj.updatedAt = JsonUtil.getTimestamp(jsonObj, "updated_at"); - obj.itemsToRemove = JsonUtil.parseArrayOfString(JsonUtil.getArray(json, "items_to_remove")); + JsonArray __itemsToRemoveArr = JsonUtil.getJsonArray(jsonObj, "items_to_remove"); + if (__itemsToRemoveArr != null) { + obj.itemsToRemove = JsonUtil.parseArrayOfString(__itemsToRemoveArr); + } - obj.couponsToRemove = JsonUtil.parseArrayOfString(JsonUtil.getArray(json, "coupons_to_remove")); + JsonArray __couponsToRemoveArr = JsonUtil.getJsonArray(jsonObj, "coupons_to_remove"); + if (__couponsToRemoveArr != null) { + obj.couponsToRemove = JsonUtil.parseArrayOfString(__couponsToRemoveArr); + } - obj.discountsToRemove = - JsonUtil.parseArrayOfString(JsonUtil.getArray(json, "discounts_to_remove")); + JsonArray __discountsToRemoveArr = JsonUtil.getJsonArray(jsonObj, "discounts_to_remove"); + if (__discountsToRemoveArr != null) { + obj.discountsToRemove = JsonUtil.parseArrayOfString(__discountsToRemoveArr); + } - obj.deleted = JsonUtil.getBoolean(json, "deleted"); + obj.deleted = JsonUtil.getBoolean(jsonObj, "deleted"); obj.itemsToAdd = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "items_to_add")).stream() - .map(ItemsToAdd::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "items_to_add"), ItemsToAdd::fromJson); obj.itemsToUpdate = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "items_to_update")).stream() - .map(ItemsToUpdate::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "items_to_update"), ItemsToUpdate::fromJson); obj.couponsToAdd = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "coupons_to_add")).stream() - .map(CouponsToAdd::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "coupons_to_add"), CouponsToAdd::fromJson); obj.discountsToAdd = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "discounts_to_add")).stream() - .map(DiscountsToAdd::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "discounts_to_add"), DiscountsToAdd::fromJson); obj.itemTiers = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "item_tiers")).stream() - .map(ItemTiers::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "item_tiers"), ItemTiers::fromJson); - String __contractTermJson = JsonUtil.getObject(json, "contract_term"); - if (__contractTermJson != null) { - obj.contractTerm = ContractTerm.fromJson(__contractTermJson); + JsonObject __contractTermObj = JsonUtil.getJsonObject(jsonObj, "contract_term"); + if (__contractTermObj != null) { + obj.contractTerm = ContractTerm.fromJson(__contractTermObj); } - String __statusTransitionReasonJson = JsonUtil.getObject(json, "status_transition_reason"); - if (__statusTransitionReasonJson != null) { - obj.statusTransitionReason = StatusTransitionReason.fromJson(__statusTransitionReasonJson); + JsonObject __statusTransitionReasonObj = + JsonUtil.getJsonObject(jsonObj, "status_transition_reason"); + if (__statusTransitionReasonObj != null) { + obj.statusTransitionReason = StatusTransitionReason.fromJson(__statusTransitionReasonObj); } return obj; @@ -477,39 +484,44 @@ public static ChargeOnEvent fromString(String value) { } public static ItemsToAdd fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static ItemsToAdd fromJson(JsonObject jsonObj) { ItemsToAdd obj = new ItemsToAdd(); - obj.itemPriceId = JsonUtil.getString(json, "item_price_id"); + obj.itemPriceId = JsonUtil.getString(jsonObj, "item_price_id"); - obj.itemType = ItemType.fromString(JsonUtil.getString(json, "item_type")); + obj.itemType = ItemType.fromString(JsonUtil.getString(jsonObj, "item_type")); - obj.quantity = JsonUtil.getInteger(json, "quantity"); + obj.quantity = JsonUtil.getInteger(jsonObj, "quantity"); - obj.quantityInDecimal = JsonUtil.getString(json, "quantity_in_decimal"); + obj.quantityInDecimal = JsonUtil.getString(jsonObj, "quantity_in_decimal"); - obj.unitPrice = JsonUtil.getLong(json, "unit_price"); + obj.unitPrice = JsonUtil.getLong(jsonObj, "unit_price"); - obj.unitPriceInDecimal = JsonUtil.getString(json, "unit_price_in_decimal"); + obj.unitPriceInDecimal = JsonUtil.getString(jsonObj, "unit_price_in_decimal"); - obj.amount = JsonUtil.getLong(json, "amount"); + obj.amount = JsonUtil.getLong(jsonObj, "amount"); - obj.amountInDecimal = JsonUtil.getString(json, "amount_in_decimal"); + obj.amountInDecimal = JsonUtil.getString(jsonObj, "amount_in_decimal"); - obj.freeQuantity = JsonUtil.getInteger(json, "free_quantity"); + obj.freeQuantity = JsonUtil.getInteger(jsonObj, "free_quantity"); - obj.freeQuantityInDecimal = JsonUtil.getString(json, "free_quantity_in_decimal"); + obj.freeQuantityInDecimal = JsonUtil.getString(jsonObj, "free_quantity_in_decimal"); - obj.billingCycles = JsonUtil.getInteger(json, "billing_cycles"); + obj.billingCycles = JsonUtil.getInteger(jsonObj, "billing_cycles"); - obj.servicePeriodDays = JsonUtil.getInteger(json, "service_period_days"); + obj.servicePeriodDays = JsonUtil.getInteger(jsonObj, "service_period_days"); - obj.meteredQuantity = JsonUtil.getString(json, "metered_quantity"); + obj.meteredQuantity = JsonUtil.getString(jsonObj, "metered_quantity"); - obj.chargeOnce = JsonUtil.getBoolean(json, "charge_once"); + obj.chargeOnce = JsonUtil.getBoolean(jsonObj, "charge_once"); - obj.chargeOnOption = ChargeOnOption.fromString(JsonUtil.getString(json, "charge_on_option")); + obj.chargeOnOption = + ChargeOnOption.fromString(JsonUtil.getString(jsonObj, "charge_on_option")); - obj.chargeOnEvent = ChargeOnEvent.fromString(JsonUtil.getString(json, "charge_on_event")); + obj.chargeOnEvent = ChargeOnEvent.fromString(JsonUtil.getString(jsonObj, "charge_on_event")); return obj; } @@ -773,39 +785,44 @@ public static ChargeOnEvent fromString(String value) { } public static ItemsToUpdate fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static ItemsToUpdate fromJson(JsonObject jsonObj) { ItemsToUpdate obj = new ItemsToUpdate(); - obj.itemPriceId = JsonUtil.getString(json, "item_price_id"); + obj.itemPriceId = JsonUtil.getString(jsonObj, "item_price_id"); - obj.itemType = ItemType.fromString(JsonUtil.getString(json, "item_type")); + obj.itemType = ItemType.fromString(JsonUtil.getString(jsonObj, "item_type")); - obj.quantity = JsonUtil.getInteger(json, "quantity"); + obj.quantity = JsonUtil.getInteger(jsonObj, "quantity"); - obj.quantityInDecimal = JsonUtil.getString(json, "quantity_in_decimal"); + obj.quantityInDecimal = JsonUtil.getString(jsonObj, "quantity_in_decimal"); - obj.unitPrice = JsonUtil.getLong(json, "unit_price"); + obj.unitPrice = JsonUtil.getLong(jsonObj, "unit_price"); - obj.unitPriceInDecimal = JsonUtil.getString(json, "unit_price_in_decimal"); + obj.unitPriceInDecimal = JsonUtil.getString(jsonObj, "unit_price_in_decimal"); - obj.amount = JsonUtil.getLong(json, "amount"); + obj.amount = JsonUtil.getLong(jsonObj, "amount"); - obj.amountInDecimal = JsonUtil.getString(json, "amount_in_decimal"); + obj.amountInDecimal = JsonUtil.getString(jsonObj, "amount_in_decimal"); - obj.freeQuantity = JsonUtil.getInteger(json, "free_quantity"); + obj.freeQuantity = JsonUtil.getInteger(jsonObj, "free_quantity"); - obj.freeQuantityInDecimal = JsonUtil.getString(json, "free_quantity_in_decimal"); + obj.freeQuantityInDecimal = JsonUtil.getString(jsonObj, "free_quantity_in_decimal"); - obj.billingCycles = JsonUtil.getInteger(json, "billing_cycles"); + obj.billingCycles = JsonUtil.getInteger(jsonObj, "billing_cycles"); - obj.servicePeriodDays = JsonUtil.getInteger(json, "service_period_days"); + obj.servicePeriodDays = JsonUtil.getInteger(jsonObj, "service_period_days"); - obj.meteredQuantity = JsonUtil.getString(json, "metered_quantity"); + obj.meteredQuantity = JsonUtil.getString(jsonObj, "metered_quantity"); - obj.chargeOnce = JsonUtil.getBoolean(json, "charge_once"); + obj.chargeOnce = JsonUtil.getBoolean(jsonObj, "charge_once"); - obj.chargeOnOption = ChargeOnOption.fromString(JsonUtil.getString(json, "charge_on_option")); + obj.chargeOnOption = + ChargeOnOption.fromString(JsonUtil.getString(jsonObj, "charge_on_option")); - obj.chargeOnEvent = ChargeOnEvent.fromString(JsonUtil.getString(json, "charge_on_event")); + obj.chargeOnEvent = ChargeOnEvent.fromString(JsonUtil.getString(jsonObj, "charge_on_event")); return obj; } @@ -909,11 +926,15 @@ public Timestamp getApplyTill() { } public static CouponsToAdd fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static CouponsToAdd fromJson(JsonObject jsonObj) { CouponsToAdd obj = new CouponsToAdd(); - obj.couponId = JsonUtil.getString(json, "coupon_id"); + obj.couponId = JsonUtil.getString(jsonObj, "coupon_id"); - obj.applyTill = JsonUtil.getTimestamp(json, "apply_till"); + obj.applyTill = JsonUtil.getTimestamp(jsonObj, "apply_till"); return obj; } @@ -1122,31 +1143,35 @@ public static ApplyOn fromString(String value) { } public static DiscountsToAdd fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static DiscountsToAdd fromJson(JsonObject jsonObj) { DiscountsToAdd obj = new DiscountsToAdd(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.invoiceName = JsonUtil.getString(json, "invoice_name"); + obj.invoiceName = JsonUtil.getString(jsonObj, "invoice_name"); - obj.type = Type.fromString(JsonUtil.getString(json, "type")); + obj.type = Type.fromString(JsonUtil.getString(jsonObj, "type")); - obj.percentage = JsonUtil.getDouble(json, "percentage"); + obj.percentage = JsonUtil.getDouble(jsonObj, "percentage"); - obj.amount = JsonUtil.getLong(json, "amount"); + obj.amount = JsonUtil.getLong(jsonObj, "amount"); - obj.durationType = DurationType.fromString(JsonUtil.getString(json, "duration_type")); + obj.durationType = DurationType.fromString(JsonUtil.getString(jsonObj, "duration_type")); - obj.period = JsonUtil.getInteger(json, "period"); + obj.period = JsonUtil.getInteger(jsonObj, "period"); - obj.periodUnit = PeriodUnit.fromString(JsonUtil.getString(json, "period_unit")); + obj.periodUnit = PeriodUnit.fromString(JsonUtil.getString(jsonObj, "period_unit")); - obj.includedInMrr = JsonUtil.getBoolean(json, "included_in_mrr"); + obj.includedInMrr = JsonUtil.getBoolean(jsonObj, "included_in_mrr"); - obj.applyOn = ApplyOn.fromString(JsonUtil.getString(json, "apply_on")); + obj.applyOn = ApplyOn.fromString(JsonUtil.getString(jsonObj, "apply_on")); - obj.itemPriceId = JsonUtil.getString(json, "item_price_id"); + obj.itemPriceId = JsonUtil.getString(jsonObj, "item_price_id"); - obj.createdAt = JsonUtil.getTimestamp(json, "created_at"); + obj.createdAt = JsonUtil.getTimestamp(jsonObj, "created_at"); return obj; } @@ -1304,27 +1329,31 @@ public static PricingType fromString(String value) { } public static ItemTiers fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static ItemTiers fromJson(JsonObject jsonObj) { ItemTiers obj = new ItemTiers(); - obj.itemPriceId = JsonUtil.getString(json, "item_price_id"); + obj.itemPriceId = JsonUtil.getString(jsonObj, "item_price_id"); - obj.startingUnit = JsonUtil.getInteger(json, "starting_unit"); + obj.startingUnit = JsonUtil.getInteger(jsonObj, "starting_unit"); - obj.endingUnit = JsonUtil.getInteger(json, "ending_unit"); + obj.endingUnit = JsonUtil.getInteger(jsonObj, "ending_unit"); - obj.price = JsonUtil.getLong(json, "price"); + obj.price = JsonUtil.getLong(jsonObj, "price"); - obj.startingUnitInDecimal = JsonUtil.getString(json, "starting_unit_in_decimal"); + obj.startingUnitInDecimal = JsonUtil.getString(jsonObj, "starting_unit_in_decimal"); - obj.endingUnitInDecimal = JsonUtil.getString(json, "ending_unit_in_decimal"); + obj.endingUnitInDecimal = JsonUtil.getString(jsonObj, "ending_unit_in_decimal"); - obj.priceInDecimal = JsonUtil.getString(json, "price_in_decimal"); + obj.priceInDecimal = JsonUtil.getString(jsonObj, "price_in_decimal"); - obj.pricingType = PricingType.fromString(JsonUtil.getString(json, "pricing_type")); + obj.pricingType = PricingType.fromString(JsonUtil.getString(jsonObj, "pricing_type")); - obj.packageSize = JsonUtil.getInteger(json, "package_size"); + obj.packageSize = JsonUtil.getInteger(jsonObj, "package_size"); - obj.index = JsonUtil.getInteger(json, "index"); + obj.index = JsonUtil.getInteger(jsonObj, "index"); return obj; } @@ -1441,14 +1470,18 @@ public static ActionAtTermEnd fromString(String value) { } public static ContractTerm fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static ContractTerm fromJson(JsonObject jsonObj) { ContractTerm obj = new ContractTerm(); - obj.cancellationCutoffPeriod = JsonUtil.getInteger(json, "cancellation_cutoff_period"); + obj.cancellationCutoffPeriod = JsonUtil.getInteger(jsonObj, "cancellation_cutoff_period"); - obj.renewalBillingCycles = JsonUtil.getInteger(json, "renewal_billing_cycles"); + obj.renewalBillingCycles = JsonUtil.getInteger(jsonObj, "renewal_billing_cycles"); obj.actionAtTermEnd = - ActionAtTermEnd.fromString(JsonUtil.getString(json, "action_at_term_end")); + ActionAtTermEnd.fromString(JsonUtil.getString(jsonObj, "action_at_term_end")); return obj; } @@ -1498,11 +1531,15 @@ public String getMessage() { } public static StatusTransitionReason fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static StatusTransitionReason fromJson(JsonObject jsonObj) { StatusTransitionReason obj = new StatusTransitionReason(); - obj.code = JsonUtil.getString(json, "code"); + obj.code = JsonUtil.getString(jsonObj, "code"); - obj.message = JsonUtil.getString(json, "message"); + obj.message = JsonUtil.getString(jsonObj, "message"); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/ramp/responses/RampCreateForSubscriptionResponse.java b/src/main/java/com/chargebee/v4/models/ramp/responses/RampCreateForSubscriptionResponse.java index 941c0e34..0337339f 100644 --- a/src/main/java/com/chargebee/v4/models/ramp/responses/RampCreateForSubscriptionResponse.java +++ b/src/main/java/com/chargebee/v4/models/ramp/responses/RampCreateForSubscriptionResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static RampCreateForSubscriptionResponse fromJson(String json) { /** Parse JSON response into RampCreateForSubscriptionResponse object with HTTP response. */ public static RampCreateForSubscriptionResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __rampJson = JsonUtil.getObject(json, "ramp"); - if (__rampJson != null) { - builder.ramp(Ramp.fromJson(__rampJson)); + JsonObject __rampObj = JsonUtil.getJsonObject(jsonObj, "ramp"); + if (__rampObj != null) { + builder.ramp(Ramp.fromJson(__rampObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/ramp/responses/RampDeleteResponse.java b/src/main/java/com/chargebee/v4/models/ramp/responses/RampDeleteResponse.java index 8b4b84d6..66cd2aa7 100644 --- a/src/main/java/com/chargebee/v4/models/ramp/responses/RampDeleteResponse.java +++ b/src/main/java/com/chargebee/v4/models/ramp/responses/RampDeleteResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** Immutable response object for RampDelete operation. Contains the response data from the API. */ @@ -24,11 +25,12 @@ public static RampDeleteResponse fromJson(String json) { /** Parse JSON response into RampDeleteResponse object with HTTP response. */ public static RampDeleteResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __rampJson = JsonUtil.getObject(json, "ramp"); - if (__rampJson != null) { - builder.ramp(Ramp.fromJson(__rampJson)); + JsonObject __rampObj = JsonUtil.getJsonObject(jsonObj, "ramp"); + if (__rampObj != null) { + builder.ramp(Ramp.fromJson(__rampObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/ramp/responses/RampListResponse.java b/src/main/java/com/chargebee/v4/models/ramp/responses/RampListResponse.java index a24273b0..0ac98853 100644 --- a/src/main/java/com/chargebee/v4/models/ramp/responses/RampListResponse.java +++ b/src/main/java/com/chargebee/v4/models/ramp/responses/RampListResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.exceptions.ChargebeeException; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; import com.chargebee.v4.services.RampService; import com.chargebee.v4.models.ramp.params.RampListParams; @@ -43,13 +44,12 @@ private RampListResponse( */ public static RampListResponse fromJson(String json) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(RampListItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "list"), RampListItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new RampListResponse(list, nextOffset, null, null, null); } catch (Exception e) { @@ -64,13 +64,12 @@ public static RampListResponse fromJson(String json) { public static RampListResponse fromJson( String json, RampService service, RampListParams originalParams, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(RampListItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "list"), RampListItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new RampListResponse(list, nextOffset, service, originalParams, httpResponse); } catch (Exception e) { @@ -170,11 +169,15 @@ public Ramp getRamp() { } public static RampListItem fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static RampListItem fromJson(JsonObject jsonObj) { RampListItem item = new RampListItem(); - String __rampJson = JsonUtil.getObject(json, "ramp"); - if (__rampJson != null) { - item.ramp = Ramp.fromJson(__rampJson); + JsonObject __rampObj = JsonUtil.getJsonObject(jsonObj, "ramp"); + if (__rampObj != null) { + item.ramp = Ramp.fromJson(__rampObj); } return item; diff --git a/src/main/java/com/chargebee/v4/models/ramp/responses/RampRetrieveResponse.java b/src/main/java/com/chargebee/v4/models/ramp/responses/RampRetrieveResponse.java index 4ba297d5..6ac8e250 100644 --- a/src/main/java/com/chargebee/v4/models/ramp/responses/RampRetrieveResponse.java +++ b/src/main/java/com/chargebee/v4/models/ramp/responses/RampRetrieveResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static RampRetrieveResponse fromJson(String json) { /** Parse JSON response into RampRetrieveResponse object with HTTP response. */ public static RampRetrieveResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __rampJson = JsonUtil.getObject(json, "ramp"); - if (__rampJson != null) { - builder.ramp(Ramp.fromJson(__rampJson)); + JsonObject __rampObj = JsonUtil.getJsonObject(jsonObj, "ramp"); + if (__rampObj != null) { + builder.ramp(Ramp.fromJson(__rampObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/ramp/responses/RampUpdateResponse.java b/src/main/java/com/chargebee/v4/models/ramp/responses/RampUpdateResponse.java index 6e071319..22aad3c8 100644 --- a/src/main/java/com/chargebee/v4/models/ramp/responses/RampUpdateResponse.java +++ b/src/main/java/com/chargebee/v4/models/ramp/responses/RampUpdateResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** Immutable response object for RampUpdate operation. Contains the response data from the API. */ @@ -24,11 +25,12 @@ public static RampUpdateResponse fromJson(String json) { /** Parse JSON response into RampUpdateResponse object with HTTP response. */ public static RampUpdateResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __rampJson = JsonUtil.getObject(json, "ramp"); - if (__rampJson != null) { - builder.ramp(Ramp.fromJson(__rampJson)); + JsonObject __rampObj = JsonUtil.getJsonObject(jsonObj, "ramp"); + if (__rampObj != null) { + builder.ramp(Ramp.fromJson(__rampObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/recordedPurchase/RecordedPurchase.java b/src/main/java/com/chargebee/v4/models/recordedPurchase/RecordedPurchase.java index 3cc076a8..26c9de2c 100644 --- a/src/main/java/com/chargebee/v4/models/recordedPurchase/RecordedPurchase.java +++ b/src/main/java/com/chargebee/v4/models/recordedPurchase/RecordedPurchase.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.recordedPurchase; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import java.sql.Timestamp; import java.util.List; @@ -130,39 +131,41 @@ public static Status fromString(String value) { } public static RecordedPurchase fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static RecordedPurchase fromJson(JsonObject jsonObj) { RecordedPurchase obj = new RecordedPurchase(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.customerId = JsonUtil.getString(json, "customer_id"); + obj.customerId = JsonUtil.getString(jsonObj, "customer_id"); - obj.appId = JsonUtil.getString(json, "app_id"); + obj.appId = JsonUtil.getString(jsonObj, "app_id"); - obj.source = Source.fromString(JsonUtil.getString(json, "source")); + obj.source = Source.fromString(JsonUtil.getString(jsonObj, "source")); - obj.status = Status.fromString(JsonUtil.getString(json, "status")); + obj.status = Status.fromString(JsonUtil.getString(jsonObj, "status")); - obj.omnichannelTransactionId = JsonUtil.getString(json, "omnichannel_transaction_id"); + obj.omnichannelTransactionId = JsonUtil.getString(jsonObj, "omnichannel_transaction_id"); - obj.createdAt = JsonUtil.getTimestamp(json, "created_at"); + obj.createdAt = JsonUtil.getTimestamp(jsonObj, "created_at"); - obj.resourceVersion = JsonUtil.getLong(json, "resource_version"); + obj.resourceVersion = JsonUtil.getLong(jsonObj, "resource_version"); obj.linkedOmnichannelSubscriptions = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "linked_omnichannel_subscriptions")) - .stream() - .map(LinkedOmnichannelSubscriptions::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "linked_omnichannel_subscriptions"), + LinkedOmnichannelSubscriptions::fromJson); obj.linkedOmnichannelOneTimeOrders = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "linked_omnichannel_one_time_orders")) - .stream() - .map(LinkedOmnichannelOneTimeOrders::fromJson) - .collect(java.util.stream.Collectors.toList()); - - String __errorDetailJson = JsonUtil.getObject(json, "error_detail"); - if (__errorDetailJson != null) { - obj.errorDetail = ErrorDetail.fromJson(__errorDetailJson); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "linked_omnichannel_one_time_orders"), + LinkedOmnichannelOneTimeOrders::fromJson); + + JsonObject __errorDetailObj = JsonUtil.getJsonObject(jsonObj, "error_detail"); + if (__errorDetailObj != null) { + obj.errorDetail = ErrorDetail.fromJson(__errorDetailObj); } return obj; @@ -243,9 +246,13 @@ public String getOmnichannelSubscriptionId() { } public static LinkedOmnichannelSubscriptions fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static LinkedOmnichannelSubscriptions fromJson(JsonObject jsonObj) { LinkedOmnichannelSubscriptions obj = new LinkedOmnichannelSubscriptions(); - obj.omnichannelSubscriptionId = JsonUtil.getString(json, "omnichannel_subscription_id"); + obj.omnichannelSubscriptionId = JsonUtil.getString(jsonObj, "omnichannel_subscription_id"); return obj; } @@ -283,9 +290,13 @@ public String getOmnichannelOneTimeOrderId() { } public static LinkedOmnichannelOneTimeOrders fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static LinkedOmnichannelOneTimeOrders fromJson(JsonObject jsonObj) { LinkedOmnichannelOneTimeOrders obj = new LinkedOmnichannelOneTimeOrders(); - obj.omnichannelOneTimeOrderId = JsonUtil.getString(json, "omnichannel_one_time_order_id"); + obj.omnichannelOneTimeOrderId = JsonUtil.getString(jsonObj, "omnichannel_one_time_order_id"); return obj; } @@ -323,9 +334,13 @@ public String getErrorMessage() { } public static ErrorDetail fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static ErrorDetail fromJson(JsonObject jsonObj) { ErrorDetail obj = new ErrorDetail(); - obj.errorMessage = JsonUtil.getString(json, "error_message"); + obj.errorMessage = JsonUtil.getString(jsonObj, "error_message"); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/recordedPurchase/responses/RecordedPurchaseCreateResponse.java b/src/main/java/com/chargebee/v4/models/recordedPurchase/responses/RecordedPurchaseCreateResponse.java index 47a10b0a..54ba72a4 100644 --- a/src/main/java/com/chargebee/v4/models/recordedPurchase/responses/RecordedPurchaseCreateResponse.java +++ b/src/main/java/com/chargebee/v4/models/recordedPurchase/responses/RecordedPurchaseCreateResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -33,16 +34,17 @@ public static RecordedPurchaseCreateResponse fromJson(String json) { /** Parse JSON response into RecordedPurchaseCreateResponse object with HTTP response. */ public static RecordedPurchaseCreateResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __recordedPurchaseJson = JsonUtil.getObject(json, "recorded_purchase"); - if (__recordedPurchaseJson != null) { - builder.recordedPurchase(RecordedPurchase.fromJson(__recordedPurchaseJson)); + JsonObject __recordedPurchaseObj = JsonUtil.getJsonObject(jsonObj, "recorded_purchase"); + if (__recordedPurchaseObj != null) { + builder.recordedPurchase(RecordedPurchase.fromJson(__recordedPurchaseObj)); } - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - builder.customer(Customer.fromJson(__customerJson)); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + builder.customer(Customer.fromJson(__customerObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/recordedPurchase/responses/RecordedPurchaseRetrieveResponse.java b/src/main/java/com/chargebee/v4/models/recordedPurchase/responses/RecordedPurchaseRetrieveResponse.java index 581a7f40..c1bc077b 100644 --- a/src/main/java/com/chargebee/v4/models/recordedPurchase/responses/RecordedPurchaseRetrieveResponse.java +++ b/src/main/java/com/chargebee/v4/models/recordedPurchase/responses/RecordedPurchaseRetrieveResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static RecordedPurchaseRetrieveResponse fromJson(String json) { /** Parse JSON response into RecordedPurchaseRetrieveResponse object with HTTP response. */ public static RecordedPurchaseRetrieveResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __recordedPurchaseJson = JsonUtil.getObject(json, "recorded_purchase"); - if (__recordedPurchaseJson != null) { - builder.recordedPurchase(RecordedPurchase.fromJson(__recordedPurchaseJson)); + JsonObject __recordedPurchaseObj = JsonUtil.getJsonObject(jsonObj, "recorded_purchase"); + if (__recordedPurchaseObj != null) { + builder.recordedPurchase(RecordedPurchase.fromJson(__recordedPurchaseObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/resourceMigration/ResourceMigration.java b/src/main/java/com/chargebee/v4/models/resourceMigration/ResourceMigration.java index 91668e75..4176e5c5 100644 --- a/src/main/java/com/chargebee/v4/models/resourceMigration/ResourceMigration.java +++ b/src/main/java/com/chargebee/v4/models/resourceMigration/ResourceMigration.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.resourceMigration; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import java.sql.Timestamp; public class ResourceMigration { @@ -105,21 +106,25 @@ public static Status fromString(String value) { } public static ResourceMigration fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static ResourceMigration fromJson(JsonObject jsonObj) { ResourceMigration obj = new ResourceMigration(); - obj.fromSite = JsonUtil.getString(json, "from_site"); + obj.fromSite = JsonUtil.getString(jsonObj, "from_site"); - obj.entityType = EntityType.fromString(JsonUtil.getString(json, "entity_type")); + obj.entityType = EntityType.fromString(JsonUtil.getString(jsonObj, "entity_type")); - obj.entityId = JsonUtil.getString(json, "entity_id"); + obj.entityId = JsonUtil.getString(jsonObj, "entity_id"); - obj.status = Status.fromString(JsonUtil.getString(json, "status")); + obj.status = Status.fromString(JsonUtil.getString(jsonObj, "status")); - obj.errors = JsonUtil.getString(json, "errors"); + obj.errors = JsonUtil.getString(jsonObj, "errors"); - obj.createdAt = JsonUtil.getTimestamp(json, "created_at"); + obj.createdAt = JsonUtil.getTimestamp(jsonObj, "created_at"); - obj.updatedAt = JsonUtil.getTimestamp(json, "updated_at"); + obj.updatedAt = JsonUtil.getTimestamp(jsonObj, "updated_at"); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/resourceMigration/responses/ResourceMigrationRetrieveLatestResponse.java b/src/main/java/com/chargebee/v4/models/resourceMigration/responses/ResourceMigrationRetrieveLatestResponse.java index 7d8d5bab..691f0391 100644 --- a/src/main/java/com/chargebee/v4/models/resourceMigration/responses/ResourceMigrationRetrieveLatestResponse.java +++ b/src/main/java/com/chargebee/v4/models/resourceMigration/responses/ResourceMigrationRetrieveLatestResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -28,11 +29,12 @@ public static ResourceMigrationRetrieveLatestResponse fromJson(String json) { public static ResourceMigrationRetrieveLatestResponse fromJson( String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __resourceMigrationJson = JsonUtil.getObject(json, "resource_migration"); - if (__resourceMigrationJson != null) { - builder.resourceMigration(ResourceMigration.fromJson(__resourceMigrationJson)); + JsonObject __resourceMigrationObj = JsonUtil.getJsonObject(jsonObj, "resource_migration"); + if (__resourceMigrationObj != null) { + builder.resourceMigration(ResourceMigration.fromJson(__resourceMigrationObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/rule/Rule.java b/src/main/java/com/chargebee/v4/models/rule/Rule.java index 0ada2ad1..ca977006 100644 --- a/src/main/java/com/chargebee/v4/models/rule/Rule.java +++ b/src/main/java/com/chargebee/v4/models/rule/Rule.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.rule; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import java.sql.Timestamp; public class Rule { @@ -92,27 +93,31 @@ public static Status fromString(String value) { } public static Rule fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Rule fromJson(JsonObject jsonObj) { Rule obj = new Rule(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.namespace = JsonUtil.getString(json, "namespace"); + obj.namespace = JsonUtil.getString(jsonObj, "namespace"); - obj.ruleName = JsonUtil.getString(json, "rule_name"); + obj.ruleName = JsonUtil.getString(jsonObj, "rule_name"); - obj.ruleOrder = JsonUtil.getInteger(json, "rule_order"); + obj.ruleOrder = JsonUtil.getInteger(jsonObj, "rule_order"); - obj.status = Status.fromString(JsonUtil.getString(json, "status")); + obj.status = Status.fromString(JsonUtil.getString(jsonObj, "status")); - obj.conditions = JsonUtil.getString(json, "conditions"); + obj.conditions = JsonUtil.getString(jsonObj, "conditions"); - obj.outcome = JsonUtil.getString(json, "outcome"); + obj.outcome = JsonUtil.getString(jsonObj, "outcome"); - obj.deleted = JsonUtil.getBoolean(json, "deleted"); + obj.deleted = JsonUtil.getBoolean(jsonObj, "deleted"); - obj.createdAt = JsonUtil.getTimestamp(json, "created_at"); + obj.createdAt = JsonUtil.getTimestamp(jsonObj, "created_at"); - obj.modifiedAt = JsonUtil.getTimestamp(json, "modified_at"); + obj.modifiedAt = JsonUtil.getTimestamp(jsonObj, "modified_at"); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/rule/responses/RuleRetrieveResponse.java b/src/main/java/com/chargebee/v4/models/rule/responses/RuleRetrieveResponse.java index 72e042c8..b12ea46e 100644 --- a/src/main/java/com/chargebee/v4/models/rule/responses/RuleRetrieveResponse.java +++ b/src/main/java/com/chargebee/v4/models/rule/responses/RuleRetrieveResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static RuleRetrieveResponse fromJson(String json) { /** Parse JSON response into RuleRetrieveResponse object with HTTP response. */ public static RuleRetrieveResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __ruleJson = JsonUtil.getObject(json, "rule"); - if (__ruleJson != null) { - builder.rule(Rule.fromJson(__ruleJson)); + JsonObject __ruleObj = JsonUtil.getJsonObject(jsonObj, "rule"); + if (__ruleObj != null) { + builder.rule(Rule.fromJson(__ruleObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/salesOrder/SalesOrder.java b/src/main/java/com/chargebee/v4/models/salesOrder/SalesOrder.java index 22e094c9..27c288cc 100644 --- a/src/main/java/com/chargebee/v4/models/salesOrder/SalesOrder.java +++ b/src/main/java/com/chargebee/v4/models/salesOrder/SalesOrder.java @@ -8,6 +8,8 @@ package com.chargebee.v4.models.salesOrder; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonArray; +import com.google.gson.JsonObject; import java.sql.Timestamp; import java.util.List; @@ -191,93 +193,99 @@ public static Status fromString(String value) { } public static SalesOrder fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static SalesOrder fromJson(JsonObject jsonObj) { SalesOrder obj = new SalesOrder(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.version = JsonUtil.getInteger(json, "version"); + obj.version = JsonUtil.getInteger(jsonObj, "version"); - obj.renewedFromOrderId = JsonUtil.getString(json, "renewed_from_order_id"); + obj.renewedFromOrderId = JsonUtil.getString(jsonObj, "renewed_from_order_id"); - obj.updatedAt = JsonUtil.getTimestamp(json, "updated_at"); + obj.updatedAt = JsonUtil.getTimestamp(jsonObj, "updated_at"); - obj.createdAt = JsonUtil.getTimestamp(json, "created_at"); + obj.createdAt = JsonUtil.getTimestamp(jsonObj, "created_at"); - obj.poNumber = JsonUtil.getString(json, "po_number"); + obj.poNumber = JsonUtil.getString(jsonObj, "po_number"); - obj.metaData = JsonUtil.getString(json, "meta_data"); + obj.metaData = JsonUtil.getString(jsonObj, "meta_data"); - obj.quoteId = JsonUtil.getString(json, "quote_id"); + obj.quoteId = JsonUtil.getString(jsonObj, "quote_id"); - obj.effectiveDate = JsonUtil.getTimestamp(json, "effective_date"); + obj.effectiveDate = JsonUtil.getTimestamp(jsonObj, "effective_date"); - obj.endDate = JsonUtil.getTimestamp(json, "end_date"); + obj.endDate = JsonUtil.getTimestamp(jsonObj, "end_date"); - obj.businessEntityId = JsonUtil.getString(json, "business_entity_id"); + obj.businessEntityId = JsonUtil.getString(jsonObj, "business_entity_id"); - obj.customerId = JsonUtil.getString(json, "customer_id"); + obj.customerId = JsonUtil.getString(jsonObj, "customer_id"); - obj.subscriptionId = JsonUtil.getString(json, "subscription_id"); + obj.subscriptionId = JsonUtil.getString(jsonObj, "subscription_id"); - obj.currencyCode = JsonUtil.getString(json, "currency_code"); + obj.currencyCode = JsonUtil.getString(jsonObj, "currency_code"); - obj.subscriptionIds = JsonUtil.parseArrayOfString(JsonUtil.getArray(json, "subscription_ids")); + JsonArray __subscriptionIdsArr = JsonUtil.getJsonArray(jsonObj, "subscription_ids"); + if (__subscriptionIdsArr != null) { + obj.subscriptionIds = JsonUtil.parseArrayOfString(__subscriptionIdsArr); + } - obj.status = Status.fromString(JsonUtil.getString(json, "status")); + obj.status = Status.fromString(JsonUtil.getString(jsonObj, "status")); - obj.invoiceIds = JsonUtil.parseArrayOfString(JsonUtil.getArray(json, "invoice_ids")); + JsonArray __invoiceIdsArr = JsonUtil.getJsonArray(jsonObj, "invoice_ids"); + if (__invoiceIdsArr != null) { + obj.invoiceIds = JsonUtil.parseArrayOfString(__invoiceIdsArr); + } - obj.creditNoteIds = JsonUtil.parseArrayOfString(JsonUtil.getArray(json, "credit_note_ids")); + JsonArray __creditNoteIdsArr = JsonUtil.getJsonArray(jsonObj, "credit_note_ids"); + if (__creditNoteIdsArr != null) { + obj.creditNoteIds = JsonUtil.parseArrayOfString(__creditNoteIdsArr); + } - obj.unbilledChargeIds = - JsonUtil.parseArrayOfString(JsonUtil.getArray(json, "unbilled_charge_ids")); + JsonArray __unbilledChargeIdsArr = JsonUtil.getJsonArray(jsonObj, "unbilled_charge_ids"); + if (__unbilledChargeIdsArr != null) { + obj.unbilledChargeIds = JsonUtil.parseArrayOfString(__unbilledChargeIdsArr); + } - obj.deleted = JsonUtil.getBoolean(json, "deleted"); + obj.deleted = JsonUtil.getBoolean(jsonObj, "deleted"); obj.lineItems = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "line_items")).stream() - .map(LineItems::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "line_items"), LineItems::fromJson); obj.billingAddresses = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "billing_addresses")).stream() - .map(BillingAddresses::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "billing_addresses"), BillingAddresses::fromJson); obj.discounts = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "discounts")).stream() - .map(Discounts::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "discounts"), Discounts::fromJson); obj.shippingAddresses = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "shipping_addresses")).stream() - .map(ShippingAddresses::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "shipping_addresses"), ShippingAddresses::fromJson); obj.lineItemTiers = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "line_item_tiers")).stream() - .map(LineItemTiers::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "line_item_tiers"), LineItemTiers::fromJson); - String __paymentConfigurationJson = JsonUtil.getObject(json, "payment_configuration"); - if (__paymentConfigurationJson != null) { - obj.paymentConfiguration = PaymentConfiguration.fromJson(__paymentConfigurationJson); + JsonObject __paymentConfigurationObj = JsonUtil.getJsonObject(jsonObj, "payment_configuration"); + if (__paymentConfigurationObj != null) { + obj.paymentConfiguration = PaymentConfiguration.fromJson(__paymentConfigurationObj); } - String __billingConfigurationJson = JsonUtil.getObject(json, "billing_configuration"); - if (__billingConfigurationJson != null) { - obj.billingConfiguration = BillingConfiguration.fromJson(__billingConfigurationJson); + JsonObject __billingConfigurationObj = JsonUtil.getJsonObject(jsonObj, "billing_configuration"); + if (__billingConfigurationObj != null) { + obj.billingConfiguration = BillingConfiguration.fromJson(__billingConfigurationObj); } - String __renewalTermJson = JsonUtil.getObject(json, "renewal_term"); - if (__renewalTermJson != null) { - obj.renewalTerm = RenewalTerm.fromJson(__renewalTermJson); + JsonObject __renewalTermObj = JsonUtil.getJsonObject(jsonObj, "renewal_term"); + if (__renewalTermObj != null) { + obj.renewalTerm = RenewalTerm.fromJson(__renewalTermObj); } obj.creditLines = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "credit_lines")).stream() - .map(CreditLines::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "credit_lines"), CreditLines::fromJson); return obj; } @@ -657,50 +665,55 @@ public static FreePeriodUnit fromString(String value) { } public static LineItems fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static LineItems fromJson(JsonObject jsonObj) { LineItems obj = new LineItems(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.associationId = JsonUtil.getString(json, "association_id"); + obj.associationId = JsonUtil.getString(jsonObj, "association_id"); - obj.itemPriceId = JsonUtil.getString(json, "item_price_id"); + obj.itemPriceId = JsonUtil.getString(jsonObj, "item_price_id"); - obj.name = JsonUtil.getString(json, "name"); + obj.name = JsonUtil.getString(jsonObj, "name"); - obj.quantity = JsonUtil.getString(json, "quantity"); + obj.quantity = JsonUtil.getString(jsonObj, "quantity"); - obj.unitPrice = JsonUtil.getString(json, "unit_price"); + obj.unitPrice = JsonUtil.getString(jsonObj, "unit_price"); - obj.billableUnitPrice = JsonUtil.getString(json, "billable_unit_price"); + obj.billableUnitPrice = JsonUtil.getString(jsonObj, "billable_unit_price"); - obj.billableQuantity = JsonUtil.getString(json, "billable_quantity"); + obj.billableQuantity = JsonUtil.getString(jsonObj, "billable_quantity"); - obj.billableAmount = JsonUtil.getString(json, "billable_amount"); + obj.billableAmount = JsonUtil.getString(jsonObj, "billable_amount"); - obj.billingPeriod = JsonUtil.getInteger(json, "billing_period"); + obj.billingPeriod = JsonUtil.getInteger(jsonObj, "billing_period"); obj.billingPeriodUnit = - BillingPeriodUnit.fromString(JsonUtil.getString(json, "billing_period_unit")); + BillingPeriodUnit.fromString(JsonUtil.getString(jsonObj, "billing_period_unit")); - obj.servicePeriodDays = JsonUtil.getInteger(json, "service_period_days"); + obj.servicePeriodDays = JsonUtil.getInteger(jsonObj, "service_period_days"); - obj.chargeOnEvent = ChargeOnEvent.fromString(JsonUtil.getString(json, "charge_on_event")); + obj.chargeOnEvent = ChargeOnEvent.fromString(JsonUtil.getString(jsonObj, "charge_on_event")); - obj.chargeOnce = JsonUtil.getBoolean(json, "charge_once"); + obj.chargeOnce = JsonUtil.getBoolean(jsonObj, "charge_once"); - obj.billingCycles = JsonUtil.getInteger(json, "billing_cycles"); + obj.billingCycles = JsonUtil.getInteger(jsonObj, "billing_cycles"); - obj.billingType = BillingType.fromString(JsonUtil.getString(json, "billing_type")); + obj.billingType = BillingType.fromString(JsonUtil.getString(jsonObj, "billing_type")); - obj.startDate = JsonUtil.getTimestamp(json, "start_date"); + obj.startDate = JsonUtil.getTimestamp(jsonObj, "start_date"); - obj.endDate = JsonUtil.getTimestamp(json, "end_date"); + obj.endDate = JsonUtil.getTimestamp(jsonObj, "end_date"); - obj.trialEnd = JsonUtil.getTimestamp(json, "trial_end"); + obj.trialEnd = JsonUtil.getTimestamp(jsonObj, "trial_end"); - obj.freePeriod = JsonUtil.getInteger(json, "free_period"); + obj.freePeriod = JsonUtil.getInteger(jsonObj, "free_period"); - obj.freePeriodUnit = FreePeriodUnit.fromString(JsonUtil.getString(json, "free_period_unit")); + obj.freePeriodUnit = + FreePeriodUnit.fromString(JsonUtil.getString(jsonObj, "free_period_unit")); return obj; } @@ -916,36 +929,40 @@ public static ValidationStatus fromString(String value) { } public static BillingAddresses fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static BillingAddresses fromJson(JsonObject jsonObj) { BillingAddresses obj = new BillingAddresses(); - obj.firstName = JsonUtil.getString(json, "first_name"); + obj.firstName = JsonUtil.getString(jsonObj, "first_name"); - obj.lastName = JsonUtil.getString(json, "last_name"); + obj.lastName = JsonUtil.getString(jsonObj, "last_name"); - obj.email = JsonUtil.getString(json, "email"); + obj.email = JsonUtil.getString(jsonObj, "email"); - obj.company = JsonUtil.getString(json, "company"); + obj.company = JsonUtil.getString(jsonObj, "company"); - obj.phone = JsonUtil.getString(json, "phone"); + obj.phone = JsonUtil.getString(jsonObj, "phone"); - obj.line1 = JsonUtil.getString(json, "line1"); + obj.line1 = JsonUtil.getString(jsonObj, "line1"); - obj.line2 = JsonUtil.getString(json, "line2"); + obj.line2 = JsonUtil.getString(jsonObj, "line2"); - obj.line3 = JsonUtil.getString(json, "line3"); + obj.line3 = JsonUtil.getString(jsonObj, "line3"); - obj.city = JsonUtil.getString(json, "city"); + obj.city = JsonUtil.getString(jsonObj, "city"); - obj.stateCode = JsonUtil.getString(json, "state_code"); + obj.stateCode = JsonUtil.getString(jsonObj, "state_code"); - obj.state = JsonUtil.getString(json, "state"); + obj.state = JsonUtil.getString(jsonObj, "state"); - obj.country = JsonUtil.getString(json, "country"); + obj.country = JsonUtil.getString(jsonObj, "country"); - obj.zip = JsonUtil.getString(json, "zip"); + obj.zip = JsonUtil.getString(jsonObj, "zip"); obj.validationStatus = - ValidationStatus.fromString(JsonUtil.getString(json, "validation_status")); + ValidationStatus.fromString(JsonUtil.getString(jsonObj, "validation_status")); return obj; } @@ -1216,33 +1233,37 @@ public static PeriodUnit fromString(String value) { } public static Discounts fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Discounts fromJson(JsonObject jsonObj) { Discounts obj = new Discounts(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.invoiceName = JsonUtil.getString(json, "invoice_name"); + obj.invoiceName = JsonUtil.getString(jsonObj, "invoice_name"); - obj.type = Type.fromString(JsonUtil.getString(json, "type")); + obj.type = Type.fromString(JsonUtil.getString(jsonObj, "type")); - obj.applyOn = ApplyOn.fromString(JsonUtil.getString(json, "apply_on")); + obj.applyOn = ApplyOn.fromString(JsonUtil.getString(jsonObj, "apply_on")); - obj.durationType = DurationType.fromString(JsonUtil.getString(json, "duration_type")); + obj.durationType = DurationType.fromString(JsonUtil.getString(jsonObj, "duration_type")); - obj.percentage = JsonUtil.getDouble(json, "percentage"); + obj.percentage = JsonUtil.getDouble(jsonObj, "percentage"); - obj.amount = JsonUtil.getString(json, "amount"); + obj.amount = JsonUtil.getString(jsonObj, "amount"); - obj.couponId = JsonUtil.getString(json, "coupon_id"); + obj.couponId = JsonUtil.getString(jsonObj, "coupon_id"); - obj.period = JsonUtil.getInteger(json, "period"); + obj.period = JsonUtil.getInteger(jsonObj, "period"); - obj.periodUnit = PeriodUnit.fromString(JsonUtil.getString(json, "period_unit")); + obj.periodUnit = PeriodUnit.fromString(JsonUtil.getString(jsonObj, "period_unit")); - obj.itemPriceId = JsonUtil.getString(json, "item_price_id"); + obj.itemPriceId = JsonUtil.getString(jsonObj, "item_price_id"); - obj.startDate = JsonUtil.getTimestamp(json, "start_date"); + obj.startDate = JsonUtil.getTimestamp(jsonObj, "start_date"); - obj.endDate = JsonUtil.getTimestamp(json, "end_date"); + obj.endDate = JsonUtil.getTimestamp(jsonObj, "end_date"); return obj; } @@ -1426,36 +1447,40 @@ public static ValidationStatus fromString(String value) { } public static ShippingAddresses fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static ShippingAddresses fromJson(JsonObject jsonObj) { ShippingAddresses obj = new ShippingAddresses(); - obj.firstName = JsonUtil.getString(json, "first_name"); + obj.firstName = JsonUtil.getString(jsonObj, "first_name"); - obj.lastName = JsonUtil.getString(json, "last_name"); + obj.lastName = JsonUtil.getString(jsonObj, "last_name"); - obj.email = JsonUtil.getString(json, "email"); + obj.email = JsonUtil.getString(jsonObj, "email"); - obj.company = JsonUtil.getString(json, "company"); + obj.company = JsonUtil.getString(jsonObj, "company"); - obj.phone = JsonUtil.getString(json, "phone"); + obj.phone = JsonUtil.getString(jsonObj, "phone"); - obj.line1 = JsonUtil.getString(json, "line1"); + obj.line1 = JsonUtil.getString(jsonObj, "line1"); - obj.line2 = JsonUtil.getString(json, "line2"); + obj.line2 = JsonUtil.getString(jsonObj, "line2"); - obj.line3 = JsonUtil.getString(json, "line3"); + obj.line3 = JsonUtil.getString(jsonObj, "line3"); - obj.city = JsonUtil.getString(json, "city"); + obj.city = JsonUtil.getString(jsonObj, "city"); - obj.stateCode = JsonUtil.getString(json, "state_code"); + obj.stateCode = JsonUtil.getString(jsonObj, "state_code"); - obj.state = JsonUtil.getString(json, "state"); + obj.state = JsonUtil.getString(jsonObj, "state"); - obj.country = JsonUtil.getString(json, "country"); + obj.country = JsonUtil.getString(jsonObj, "country"); - obj.zip = JsonUtil.getString(json, "zip"); + obj.zip = JsonUtil.getString(jsonObj, "zip"); obj.validationStatus = - ValidationStatus.fromString(JsonUtil.getString(json, "validation_status")); + ValidationStatus.fromString(JsonUtil.getString(jsonObj, "validation_status")); return obj; } @@ -1601,19 +1626,23 @@ public static PricingType fromString(String value) { } public static LineItemTiers fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static LineItemTiers fromJson(JsonObject jsonObj) { LineItemTiers obj = new LineItemTiers(); - obj.startingUnit = JsonUtil.getString(json, "starting_unit"); + obj.startingUnit = JsonUtil.getString(jsonObj, "starting_unit"); - obj.endingUnit = JsonUtil.getString(json, "ending_unit"); + obj.endingUnit = JsonUtil.getString(jsonObj, "ending_unit"); - obj.price = JsonUtil.getString(json, "price"); + obj.price = JsonUtil.getString(jsonObj, "price"); - obj.pricingType = PricingType.fromString(JsonUtil.getString(json, "pricing_type")); + obj.pricingType = PricingType.fromString(JsonUtil.getString(jsonObj, "pricing_type")); - obj.packageSize = JsonUtil.getInteger(json, "package_size"); + obj.packageSize = JsonUtil.getInteger(jsonObj, "package_size"); - obj.lineItemAssociationId = JsonUtil.getString(json, "line_item_association_id"); + obj.lineItemAssociationId = JsonUtil.getString(jsonObj, "line_item_association_id"); return obj; } @@ -1762,16 +1791,21 @@ public static OfflinePaymentMethod fromString(String value) { } public static PaymentConfiguration fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static PaymentConfiguration fromJson(JsonObject jsonObj) { PaymentConfiguration obj = new PaymentConfiguration(); - obj.autoCollection = AutoCollection.fromString(JsonUtil.getString(json, "auto_collection")); + obj.autoCollection = + AutoCollection.fromString(JsonUtil.getString(jsonObj, "auto_collection")); - obj.paymentSourceId = JsonUtil.getString(json, "payment_source_id"); + obj.paymentSourceId = JsonUtil.getString(jsonObj, "payment_source_id"); - obj.paymentIntentId = JsonUtil.getString(json, "payment_intent_id"); + obj.paymentIntentId = JsonUtil.getString(jsonObj, "payment_intent_id"); obj.offlinePaymentMethod = - OfflinePaymentMethod.fromString(JsonUtil.getString(json, "offline_payment_method")); + OfflinePaymentMethod.fromString(JsonUtil.getString(jsonObj, "offline_payment_method")); return obj; } @@ -1884,24 +1918,28 @@ public static BillingAlignmentMode fromString(String value) { } public static BillingConfiguration fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static BillingConfiguration fromJson(JsonObject jsonObj) { BillingConfiguration obj = new BillingConfiguration(); - obj.createPendingInvoices = JsonUtil.getBoolean(json, "create_pending_invoices"); + obj.createPendingInvoices = JsonUtil.getBoolean(jsonObj, "create_pending_invoices"); - obj.invoiceImmediately = JsonUtil.getBoolean(json, "invoice_immediately"); + obj.invoiceImmediately = JsonUtil.getBoolean(jsonObj, "invoice_immediately"); - obj.firstInvoicePending = JsonUtil.getBoolean(json, "first_invoice_pending"); + obj.firstInvoicePending = JsonUtil.getBoolean(jsonObj, "first_invoice_pending"); - obj.invoiceUsages = JsonUtil.getBoolean(json, "invoice_usages"); + obj.invoiceUsages = JsonUtil.getBoolean(jsonObj, "invoice_usages"); - obj.netTermDays = JsonUtil.getInteger(json, "net_term_days"); + obj.netTermDays = JsonUtil.getInteger(jsonObj, "net_term_days"); - obj.invoiceDate = JsonUtil.getTimestamp(json, "invoice_date"); + obj.invoiceDate = JsonUtil.getTimestamp(jsonObj, "invoice_date"); - obj.billingCyclesToInvoice = JsonUtil.getInteger(json, "billing_cycles_to_invoice"); + obj.billingCyclesToInvoice = JsonUtil.getInteger(jsonObj, "billing_cycles_to_invoice"); obj.billingAlignmentMode = - BillingAlignmentMode.fromString(JsonUtil.getString(json, "billing_alignment_mode")); + BillingAlignmentMode.fromString(JsonUtil.getString(jsonObj, "billing_alignment_mode")); return obj; } @@ -2008,14 +2046,18 @@ public static EndOfTermAction fromString(String value) { } public static RenewalTerm fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static RenewalTerm fromJson(JsonObject jsonObj) { RenewalTerm obj = new RenewalTerm(); obj.endOfTermAction = - EndOfTermAction.fromString(JsonUtil.getString(json, "end_of_term_action")); + EndOfTermAction.fromString(JsonUtil.getString(jsonObj, "end_of_term_action")); - obj.cancellationCutoffPeriod = JsonUtil.getInteger(json, "cancellation_cutoff_period"); + obj.cancellationCutoffPeriod = JsonUtil.getInteger(jsonObj, "cancellation_cutoff_period"); - obj.renewalBillingCycles = JsonUtil.getInteger(json, "renewal_billing_cycles"); + obj.renewalBillingCycles = JsonUtil.getInteger(jsonObj, "renewal_billing_cycles"); return obj; } @@ -2075,15 +2117,19 @@ public String getLineItemAssociationId() { } public static CreditLines fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static CreditLines fromJson(JsonObject jsonObj) { CreditLines obj = new CreditLines(); - obj.amount = JsonUtil.getString(json, "amount"); + obj.amount = JsonUtil.getString(jsonObj, "amount"); - obj.unitPrice = JsonUtil.getString(json, "unit_price"); + obj.unitPrice = JsonUtil.getString(jsonObj, "unit_price"); - obj.quantity = JsonUtil.getString(json, "quantity"); + obj.quantity = JsonUtil.getString(jsonObj, "quantity"); - obj.lineItemAssociationId = JsonUtil.getString(json, "line_item_association_id"); + obj.lineItemAssociationId = JsonUtil.getString(jsonObj, "line_item_association_id"); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/siteMigrationDetail/SiteMigrationDetail.java b/src/main/java/com/chargebee/v4/models/siteMigrationDetail/SiteMigrationDetail.java index a9f44560..347bb7af 100644 --- a/src/main/java/com/chargebee/v4/models/siteMigrationDetail/SiteMigrationDetail.java +++ b/src/main/java/com/chargebee/v4/models/siteMigrationDetail/SiteMigrationDetail.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.siteMigrationDetail; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import java.sql.Timestamp; public class SiteMigrationDetail { @@ -110,19 +111,23 @@ public static Status fromString(String value) { } public static SiteMigrationDetail fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static SiteMigrationDetail fromJson(JsonObject jsonObj) { SiteMigrationDetail obj = new SiteMigrationDetail(); - obj.entityId = JsonUtil.getString(json, "entity_id"); + obj.entityId = JsonUtil.getString(jsonObj, "entity_id"); - obj.otherSiteName = JsonUtil.getString(json, "other_site_name"); + obj.otherSiteName = JsonUtil.getString(jsonObj, "other_site_name"); - obj.entityIdAtOtherSite = JsonUtil.getString(json, "entity_id_at_other_site"); + obj.entityIdAtOtherSite = JsonUtil.getString(jsonObj, "entity_id_at_other_site"); - obj.migratedAt = JsonUtil.getTimestamp(json, "migrated_at"); + obj.migratedAt = JsonUtil.getTimestamp(jsonObj, "migrated_at"); - obj.entityType = EntityType.fromString(JsonUtil.getString(json, "entity_type")); + obj.entityType = EntityType.fromString(JsonUtil.getString(jsonObj, "entity_type")); - obj.status = Status.fromString(JsonUtil.getString(json, "status")); + obj.status = Status.fromString(JsonUtil.getString(jsonObj, "status")); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/siteMigrationDetail/responses/SiteMigrationDetailListResponse.java b/src/main/java/com/chargebee/v4/models/siteMigrationDetail/responses/SiteMigrationDetailListResponse.java index a6cfb1b0..346cbc7e 100644 --- a/src/main/java/com/chargebee/v4/models/siteMigrationDetail/responses/SiteMigrationDetailListResponse.java +++ b/src/main/java/com/chargebee/v4/models/siteMigrationDetail/responses/SiteMigrationDetailListResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.exceptions.ChargebeeException; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; import com.chargebee.v4.services.SiteMigrationDetailService; import com.chargebee.v4.models.siteMigrationDetail.params.SiteMigrationDetailListParams; @@ -45,13 +46,13 @@ private SiteMigrationDetailListResponse( */ public static SiteMigrationDetailListResponse fromJson(String json) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(SiteMigrationDetailListItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "list"), SiteMigrationDetailListItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new SiteMigrationDetailListResponse(list, nextOffset, null, null, null); } catch (Exception e) { @@ -69,13 +70,13 @@ public static SiteMigrationDetailListResponse fromJson( SiteMigrationDetailListParams originalParams, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(SiteMigrationDetailListItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "list"), SiteMigrationDetailListItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new SiteMigrationDetailListResponse( list, nextOffset, service, originalParams, httpResponse); @@ -178,11 +179,16 @@ public SiteMigrationDetail getSiteMigrationDetail() { } public static SiteMigrationDetailListItem fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static SiteMigrationDetailListItem fromJson(JsonObject jsonObj) { SiteMigrationDetailListItem item = new SiteMigrationDetailListItem(); - String __siteMigrationDetailJson = JsonUtil.getObject(json, "site_migration_detail"); - if (__siteMigrationDetailJson != null) { - item.siteMigrationDetail = SiteMigrationDetail.fromJson(__siteMigrationDetailJson); + JsonObject __siteMigrationDetailObj = + JsonUtil.getJsonObject(jsonObj, "site_migration_detail"); + if (__siteMigrationDetailObj != null) { + item.siteMigrationDetail = SiteMigrationDetail.fromJson(__siteMigrationDetailObj); } return item; diff --git a/src/main/java/com/chargebee/v4/models/subscription/Subscription.java b/src/main/java/com/chargebee/v4/models/subscription/Subscription.java index 12022ea6..1ddf17d0 100644 --- a/src/main/java/com/chargebee/v4/models/subscription/Subscription.java +++ b/src/main/java/com/chargebee/v4/models/subscription/Subscription.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.subscription; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import java.math.BigDecimal; import java.sql.Timestamp; import java.util.List; @@ -717,9 +718,12 @@ public static AutoCollection fromString(String value) { } public static Subscription fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Subscription fromJson(JsonObject jsonObj) { Subscription obj = new Subscription(); - // Parse JSON to extract all keys for custom field extraction java.util.Set knownFields = new java.util.HashSet<>(); knownFields.add("id"); @@ -880,243 +884,199 @@ public static Subscription fromJson(String json) { knownFields.add("plan_id"); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.currencyCode = JsonUtil.getString(json, "currency_code"); + obj.currencyCode = JsonUtil.getString(jsonObj, "currency_code"); - obj.startDate = JsonUtil.getTimestamp(json, "start_date"); + obj.startDate = JsonUtil.getTimestamp(jsonObj, "start_date"); - obj.trialEnd = JsonUtil.getTimestamp(json, "trial_end"); + obj.trialEnd = JsonUtil.getTimestamp(jsonObj, "trial_end"); - obj.remainingBillingCycles = JsonUtil.getInteger(json, "remaining_billing_cycles"); + obj.remainingBillingCycles = JsonUtil.getInteger(jsonObj, "remaining_billing_cycles"); - obj.poNumber = JsonUtil.getString(json, "po_number"); + obj.poNumber = JsonUtil.getString(jsonObj, "po_number"); - obj.planQuantityInDecimal = JsonUtil.getString(json, "plan_quantity_in_decimal"); + obj.planQuantityInDecimal = JsonUtil.getString(jsonObj, "plan_quantity_in_decimal"); - obj.planUnitPriceInDecimal = JsonUtil.getString(json, "plan_unit_price_in_decimal"); + obj.planUnitPriceInDecimal = JsonUtil.getString(jsonObj, "plan_unit_price_in_decimal"); - obj.customerId = JsonUtil.getString(json, "customer_id"); + obj.customerId = JsonUtil.getString(jsonObj, "customer_id"); - obj.status = Status.fromString(JsonUtil.getString(json, "status")); + obj.status = Status.fromString(JsonUtil.getString(jsonObj, "status")); - obj.trialStart = JsonUtil.getTimestamp(json, "trial_start"); + obj.trialStart = JsonUtil.getTimestamp(jsonObj, "trial_start"); - obj.trialEndAction = TrialEndAction.fromString(JsonUtil.getString(json, "trial_end_action")); + obj.trialEndAction = TrialEndAction.fromString(JsonUtil.getString(jsonObj, "trial_end_action")); - obj.currentTermStart = JsonUtil.getTimestamp(json, "current_term_start"); + obj.currentTermStart = JsonUtil.getTimestamp(jsonObj, "current_term_start"); - obj.currentTermEnd = JsonUtil.getTimestamp(json, "current_term_end"); + obj.currentTermEnd = JsonUtil.getTimestamp(jsonObj, "current_term_end"); - obj.nextBillingAt = JsonUtil.getTimestamp(json, "next_billing_at"); + obj.nextBillingAt = JsonUtil.getTimestamp(jsonObj, "next_billing_at"); - obj.createdAt = JsonUtil.getTimestamp(json, "created_at"); + obj.createdAt = JsonUtil.getTimestamp(jsonObj, "created_at"); - obj.startedAt = JsonUtil.getTimestamp(json, "started_at"); + obj.startedAt = JsonUtil.getTimestamp(jsonObj, "started_at"); - obj.activatedAt = JsonUtil.getTimestamp(json, "activated_at"); + obj.activatedAt = JsonUtil.getTimestamp(jsonObj, "activated_at"); obj.contractTermBillingCycleOnRenewal = - JsonUtil.getInteger(json, "contract_term_billing_cycle_on_renewal"); + JsonUtil.getInteger(jsonObj, "contract_term_billing_cycle_on_renewal"); - obj.overrideRelationship = JsonUtil.getBoolean(json, "override_relationship"); + obj.overrideRelationship = JsonUtil.getBoolean(jsonObj, "override_relationship"); - obj.pauseDate = JsonUtil.getTimestamp(json, "pause_date"); + obj.pauseDate = JsonUtil.getTimestamp(jsonObj, "pause_date"); - obj.resumeDate = JsonUtil.getTimestamp(json, "resume_date"); + obj.resumeDate = JsonUtil.getTimestamp(jsonObj, "resume_date"); - obj.cancelledAt = JsonUtil.getTimestamp(json, "cancelled_at"); + obj.cancelledAt = JsonUtil.getTimestamp(jsonObj, "cancelled_at"); - obj.cancelReason = CancelReason.fromString(JsonUtil.getString(json, "cancel_reason")); + obj.cancelReason = CancelReason.fromString(JsonUtil.getString(jsonObj, "cancel_reason")); - obj.createdFromIp = JsonUtil.getString(json, "created_from_ip"); + obj.createdFromIp = JsonUtil.getString(jsonObj, "created_from_ip"); - obj.resourceVersion = JsonUtil.getLong(json, "resource_version"); + obj.resourceVersion = JsonUtil.getLong(jsonObj, "resource_version"); - obj.updatedAt = JsonUtil.getTimestamp(json, "updated_at"); + obj.updatedAt = JsonUtil.getTimestamp(jsonObj, "updated_at"); - obj.hasScheduledAdvanceInvoices = JsonUtil.getBoolean(json, "has_scheduled_advance_invoices"); + obj.hasScheduledAdvanceInvoices = + JsonUtil.getBoolean(jsonObj, "has_scheduled_advance_invoices"); - obj.hasScheduledChanges = JsonUtil.getBoolean(json, "has_scheduled_changes"); + obj.hasScheduledChanges = JsonUtil.getBoolean(jsonObj, "has_scheduled_changes"); - obj.paymentSourceId = JsonUtil.getString(json, "payment_source_id"); + obj.paymentSourceId = JsonUtil.getString(jsonObj, "payment_source_id"); - obj.planFreeQuantityInDecimal = JsonUtil.getString(json, "plan_free_quantity_in_decimal"); + obj.planFreeQuantityInDecimal = JsonUtil.getString(jsonObj, "plan_free_quantity_in_decimal"); - obj.planAmountInDecimal = JsonUtil.getString(json, "plan_amount_in_decimal"); + obj.planAmountInDecimal = JsonUtil.getString(jsonObj, "plan_amount_in_decimal"); - obj.cancelScheduleCreatedAt = JsonUtil.getTimestamp(json, "cancel_schedule_created_at"); + obj.cancelScheduleCreatedAt = JsonUtil.getTimestamp(jsonObj, "cancel_schedule_created_at"); obj.offlinePaymentMethod = - OfflinePaymentMethod.fromString(JsonUtil.getString(json, "offline_payment_method")); + OfflinePaymentMethod.fromString(JsonUtil.getString(jsonObj, "offline_payment_method")); - obj.channel = Channel.fromString(JsonUtil.getString(json, "channel")); + obj.channel = Channel.fromString(JsonUtil.getString(jsonObj, "channel")); - obj.netTermDays = JsonUtil.getInteger(json, "net_term_days"); + obj.netTermDays = JsonUtil.getInteger(jsonObj, "net_term_days"); - obj.activeId = JsonUtil.getString(json, "active_id"); + obj.activeId = JsonUtil.getString(jsonObj, "active_id"); - obj.dueInvoicesCount = JsonUtil.getInteger(json, "due_invoices_count"); + obj.dueInvoicesCount = JsonUtil.getInteger(jsonObj, "due_invoices_count"); - obj.dueSince = JsonUtil.getTimestamp(json, "due_since"); + obj.dueSince = JsonUtil.getTimestamp(jsonObj, "due_since"); - obj.totalDues = JsonUtil.getLong(json, "total_dues"); + obj.totalDues = JsonUtil.getLong(jsonObj, "total_dues"); - obj.mrr = JsonUtil.getLong(json, "mrr"); + obj.mrr = JsonUtil.getLong(jsonObj, "mrr"); - obj.arr = JsonUtil.getLong(json, "arr"); + obj.arr = JsonUtil.getLong(jsonObj, "arr"); - obj.exchangeRate = JsonUtil.getBigDecimal(json, "exchange_rate"); + obj.exchangeRate = JsonUtil.getBigDecimal(jsonObj, "exchange_rate"); - obj.baseCurrencyCode = JsonUtil.getString(json, "base_currency_code"); + obj.baseCurrencyCode = JsonUtil.getString(jsonObj, "base_currency_code"); - obj.coupon = JsonUtil.getString(json, "coupon"); + obj.coupon = JsonUtil.getString(jsonObj, "coupon"); - obj.invoiceNotes = JsonUtil.getString(json, "invoice_notes"); + obj.invoiceNotes = JsonUtil.getString(jsonObj, "invoice_notes"); - String __metaDataJson = JsonUtil.getObject(json, "meta_data"); + JsonObject __metaDataObj = JsonUtil.getJsonObject(jsonObj, "meta_data"); obj.metaData = - __metaDataJson != null - ? JsonUtil.parseJsonObjectToMap(__metaDataJson) + __metaDataObj != null + ? JsonUtil.parseJsonObjectToMap(__metaDataObj) : new java.util.HashMap<>(); - obj.deleted = JsonUtil.getBoolean(json, "deleted"); + obj.deleted = JsonUtil.getBoolean(jsonObj, "deleted"); - obj.changesScheduledAt = JsonUtil.getTimestamp(json, "changes_scheduled_at"); + obj.changesScheduledAt = JsonUtil.getTimestamp(jsonObj, "changes_scheduled_at"); - obj.cancelReasonCode = JsonUtil.getString(json, "cancel_reason_code"); + obj.cancelReasonCode = JsonUtil.getString(jsonObj, "cancel_reason_code"); - obj.freePeriod = JsonUtil.getInteger(json, "free_period"); + obj.freePeriod = JsonUtil.getInteger(jsonObj, "free_period"); - obj.freePeriodUnit = FreePeriodUnit.fromString(JsonUtil.getString(json, "free_period_unit")); + obj.freePeriodUnit = FreePeriodUnit.fromString(JsonUtil.getString(jsonObj, "free_period_unit")); - obj.createPendingInvoices = JsonUtil.getBoolean(json, "create_pending_invoices"); + obj.createPendingInvoices = JsonUtil.getBoolean(jsonObj, "create_pending_invoices"); - obj.autoCloseInvoices = JsonUtil.getBoolean(json, "auto_close_invoices"); + obj.autoCloseInvoices = JsonUtil.getBoolean(jsonObj, "auto_close_invoices"); - obj.businessEntityId = JsonUtil.getString(json, "business_entity_id"); + obj.businessEntityId = JsonUtil.getString(jsonObj, "business_entity_id"); - obj.decommissioned = JsonUtil.getBoolean(json, "decommissioned"); + obj.decommissioned = JsonUtil.getBoolean(jsonObj, "decommissioned"); obj.subscriptionItems = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "subscription_items")).stream() - .map(SubscriptionItems::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "subscription_items"), SubscriptionItems::fromJson); obj.itemTiers = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "item_tiers")).stream() - .map(ItemTiers::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "item_tiers"), ItemTiers::fromJson); obj.chargedItems = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "charged_items")).stream() - .map(ChargedItems::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "charged_items"), ChargedItems::fromJson); - obj.coupons = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "coupons")).stream() - .map(Coupons::fromJson) - .collect(java.util.stream.Collectors.toList()); + obj.coupons = JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "coupons"), Coupons::fromJson); - String __shippingAddressJson = JsonUtil.getObject(json, "shipping_address"); - if (__shippingAddressJson != null) { - obj.shippingAddress = ShippingAddress.fromJson(__shippingAddressJson); + JsonObject __shippingAddressObj = JsonUtil.getJsonObject(jsonObj, "shipping_address"); + if (__shippingAddressObj != null) { + obj.shippingAddress = ShippingAddress.fromJson(__shippingAddressObj); } - String __referralInfoJson = JsonUtil.getObject(json, "referral_info"); - if (__referralInfoJson != null) { - obj.referralInfo = ReferralInfo.fromJson(__referralInfoJson); + JsonObject __referralInfoObj = JsonUtil.getJsonObject(jsonObj, "referral_info"); + if (__referralInfoObj != null) { + obj.referralInfo = ReferralInfo.fromJson(__referralInfoObj); } - String __billingOverrideJson = JsonUtil.getObject(json, "billing_override"); - if (__billingOverrideJson != null) { - obj.billingOverride = BillingOverride.fromJson(__billingOverrideJson); + JsonObject __billingOverrideObj = JsonUtil.getJsonObject(jsonObj, "billing_override"); + if (__billingOverrideObj != null) { + obj.billingOverride = BillingOverride.fromJson(__billingOverrideObj); } - String __contractTermJson = JsonUtil.getObject(json, "contract_term"); - if (__contractTermJson != null) { - obj.contractTerm = ContractTerm.fromJson(__contractTermJson); + JsonObject __contractTermObj = JsonUtil.getJsonObject(jsonObj, "contract_term"); + if (__contractTermObj != null) { + obj.contractTerm = ContractTerm.fromJson(__contractTermObj); } obj.discounts = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "discounts")).stream() - .map(Discounts::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "discounts"), Discounts::fromJson); - obj.billingPeriod = JsonUtil.getInteger(json, "billing_period"); + obj.billingPeriod = JsonUtil.getInteger(jsonObj, "billing_period"); - obj.setupFee = JsonUtil.getLong(json, "setup_fee"); + obj.setupFee = JsonUtil.getLong(jsonObj, "setup_fee"); - obj.planFreeQuantity = JsonUtil.getInteger(json, "plan_free_quantity"); + obj.planFreeQuantity = JsonUtil.getInteger(jsonObj, "plan_free_quantity"); - obj.addons = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "addons")).stream() - .map(Addons::fromJson) - .collect(java.util.stream.Collectors.toList()); + obj.addons = JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "addons"), Addons::fromJson); obj.billingPeriodUnit = - BillingPeriodUnit.fromString(JsonUtil.getString(json, "billing_period_unit")); + BillingPeriodUnit.fromString(JsonUtil.getString(jsonObj, "billing_period_unit")); - obj.giftId = JsonUtil.getString(json, "gift_id"); + obj.giftId = JsonUtil.getString(jsonObj, "gift_id"); - obj.planQuantity = JsonUtil.getInteger(json, "plan_quantity"); + obj.planQuantity = JsonUtil.getInteger(jsonObj, "plan_quantity"); - obj.affiliateToken = JsonUtil.getString(json, "affiliate_token"); + obj.affiliateToken = JsonUtil.getString(jsonObj, "affiliate_token"); - obj.planAmount = JsonUtil.getLong(json, "plan_amount"); + obj.planAmount = JsonUtil.getLong(jsonObj, "plan_amount"); - obj.planUnitPrice = JsonUtil.getLong(json, "plan_unit_price"); + obj.planUnitPrice = JsonUtil.getLong(jsonObj, "plan_unit_price"); obj.chargedEventBasedAddons = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "charged_event_based_addons")).stream() - .map(ChargedEventBasedAddons::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "charged_event_based_addons"), + ChargedEventBasedAddons::fromJson); - obj.autoCollection = AutoCollection.fromString(JsonUtil.getString(json, "auto_collection")); + obj.autoCollection = AutoCollection.fromString(JsonUtil.getString(jsonObj, "auto_collection")); obj.eventBasedAddons = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "event_based_addons")).stream() - .map(EventBasedAddons::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "event_based_addons"), EventBasedAddons::fromJson); - obj.planId = JsonUtil.getString(json, "plan_id"); + obj.planId = JsonUtil.getString(jsonObj, "plan_id"); - // Extract custom fields (fields starting with cf_) - obj.customFields = extractCustomFields(json, knownFields); + obj.customFields = JsonUtil.extractCustomFields(jsonObj, knownFields); return obj; } - /** - * Helper method to extract custom fields from JSON. Custom fields are fields that start with - * "cf_" and are not in the known fields set. - * - * @param json JSON string to parse - * @param knownFields set of known field names - * @return map of custom fields - */ - private static java.util.Map extractCustomFields( - String json, java.util.Set knownFields) { - java.util.Map customFields = new java.util.HashMap<>(); - try { - // Parse the entire JSON as a map - java.util.Map allFields = JsonUtil.parseJsonObjectToMap(json); - if (allFields != null) { - for (java.util.Map.Entry entry : allFields.entrySet()) { - String key = entry.getKey(); - // Include fields that start with "cf_" and are not in knownFields - if (key != null && key.startsWith("cf_") && !knownFields.contains(key)) { - customFields.put( - key, entry.getValue() != null ? String.valueOf(entry.getValue()) : null); - } - } - } - } catch (Exception e) { - // If parsing fails, return empty map - } - return customFields; - } - @Override public String toString() { return "Subscription{" @@ -1776,60 +1736,65 @@ public static UsageAccumulationResetFrequency fromString(String value) { } public static SubscriptionItems fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static SubscriptionItems fromJson(JsonObject jsonObj) { SubscriptionItems obj = new SubscriptionItems(); - obj.itemPriceId = JsonUtil.getString(json, "item_price_id"); + obj.itemPriceId = JsonUtil.getString(jsonObj, "item_price_id"); - obj.itemType = ItemType.fromString(JsonUtil.getString(json, "item_type")); + obj.itemType = ItemType.fromString(JsonUtil.getString(jsonObj, "item_type")); - obj.quantity = JsonUtil.getInteger(json, "quantity"); + obj.quantity = JsonUtil.getInteger(jsonObj, "quantity"); - obj.quantityInDecimal = JsonUtil.getString(json, "quantity_in_decimal"); + obj.quantityInDecimal = JsonUtil.getString(jsonObj, "quantity_in_decimal"); - obj.meteredQuantity = JsonUtil.getString(json, "metered_quantity"); + obj.meteredQuantity = JsonUtil.getString(jsonObj, "metered_quantity"); - obj.lastCalculatedAt = JsonUtil.getTimestamp(json, "last_calculated_at"); + obj.lastCalculatedAt = JsonUtil.getTimestamp(jsonObj, "last_calculated_at"); - obj.unitPrice = JsonUtil.getLong(json, "unit_price"); + obj.unitPrice = JsonUtil.getLong(jsonObj, "unit_price"); - obj.unitPriceInDecimal = JsonUtil.getString(json, "unit_price_in_decimal"); + obj.unitPriceInDecimal = JsonUtil.getString(jsonObj, "unit_price_in_decimal"); - obj.amount = JsonUtil.getLong(json, "amount"); + obj.amount = JsonUtil.getLong(jsonObj, "amount"); - obj.currentTermStart = JsonUtil.getTimestamp(json, "current_term_start"); + obj.currentTermStart = JsonUtil.getTimestamp(jsonObj, "current_term_start"); - obj.currentTermEnd = JsonUtil.getTimestamp(json, "current_term_end"); + obj.currentTermEnd = JsonUtil.getTimestamp(jsonObj, "current_term_end"); - obj.nextBillingAt = JsonUtil.getTimestamp(json, "next_billing_at"); + obj.nextBillingAt = JsonUtil.getTimestamp(jsonObj, "next_billing_at"); - obj.amountInDecimal = JsonUtil.getString(json, "amount_in_decimal"); + obj.amountInDecimal = JsonUtil.getString(jsonObj, "amount_in_decimal"); - obj.billingPeriod = JsonUtil.getInteger(json, "billing_period"); + obj.billingPeriod = JsonUtil.getInteger(jsonObj, "billing_period"); obj.billingPeriodUnit = - BillingPeriodUnit.fromString(JsonUtil.getString(json, "billing_period_unit")); + BillingPeriodUnit.fromString(JsonUtil.getString(jsonObj, "billing_period_unit")); - obj.freeQuantity = JsonUtil.getInteger(json, "free_quantity"); + obj.freeQuantity = JsonUtil.getInteger(jsonObj, "free_quantity"); - obj.freeQuantityInDecimal = JsonUtil.getString(json, "free_quantity_in_decimal"); + obj.freeQuantityInDecimal = JsonUtil.getString(jsonObj, "free_quantity_in_decimal"); - obj.trialEnd = JsonUtil.getTimestamp(json, "trial_end"); + obj.trialEnd = JsonUtil.getTimestamp(jsonObj, "trial_end"); - obj.billingCycles = JsonUtil.getInteger(json, "billing_cycles"); + obj.billingCycles = JsonUtil.getInteger(jsonObj, "billing_cycles"); - obj.servicePeriodDays = JsonUtil.getInteger(json, "service_period_days"); + obj.servicePeriodDays = JsonUtil.getInteger(jsonObj, "service_period_days"); - obj.chargeOnEvent = ChargeOnEvent.fromString(JsonUtil.getString(json, "charge_on_event")); + obj.chargeOnEvent = ChargeOnEvent.fromString(JsonUtil.getString(jsonObj, "charge_on_event")); - obj.chargeOnce = JsonUtil.getBoolean(json, "charge_once"); + obj.chargeOnce = JsonUtil.getBoolean(jsonObj, "charge_once"); - obj.chargeOnOption = ChargeOnOption.fromString(JsonUtil.getString(json, "charge_on_option")); + obj.chargeOnOption = + ChargeOnOption.fromString(JsonUtil.getString(jsonObj, "charge_on_option")); - obj.prorationType = ProrationType.fromString(JsonUtil.getString(json, "proration_type")); + obj.prorationType = ProrationType.fromString(JsonUtil.getString(jsonObj, "proration_type")); obj.usageAccumulationResetFrequency = UsageAccumulationResetFrequency.fromString( - JsonUtil.getString(json, "usage_accumulation_reset_frequency")); + JsonUtil.getString(jsonObj, "usage_accumulation_reset_frequency")); return obj; } @@ -2040,27 +2005,31 @@ public static PricingType fromString(String value) { } public static ItemTiers fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static ItemTiers fromJson(JsonObject jsonObj) { ItemTiers obj = new ItemTiers(); - obj.itemPriceId = JsonUtil.getString(json, "item_price_id"); + obj.itemPriceId = JsonUtil.getString(jsonObj, "item_price_id"); - obj.startingUnit = JsonUtil.getInteger(json, "starting_unit"); + obj.startingUnit = JsonUtil.getInteger(jsonObj, "starting_unit"); - obj.endingUnit = JsonUtil.getInteger(json, "ending_unit"); + obj.endingUnit = JsonUtil.getInteger(jsonObj, "ending_unit"); - obj.price = JsonUtil.getLong(json, "price"); + obj.price = JsonUtil.getLong(jsonObj, "price"); - obj.startingUnitInDecimal = JsonUtil.getString(json, "starting_unit_in_decimal"); + obj.startingUnitInDecimal = JsonUtil.getString(jsonObj, "starting_unit_in_decimal"); - obj.endingUnitInDecimal = JsonUtil.getString(json, "ending_unit_in_decimal"); + obj.endingUnitInDecimal = JsonUtil.getString(jsonObj, "ending_unit_in_decimal"); - obj.priceInDecimal = JsonUtil.getString(json, "price_in_decimal"); + obj.priceInDecimal = JsonUtil.getString(jsonObj, "price_in_decimal"); - obj.pricingType = PricingType.fromString(JsonUtil.getString(json, "pricing_type")); + obj.pricingType = PricingType.fromString(JsonUtil.getString(jsonObj, "pricing_type")); - obj.packageSize = JsonUtil.getInteger(json, "package_size"); + obj.packageSize = JsonUtil.getInteger(jsonObj, "package_size"); - obj.index = JsonUtil.getInteger(json, "index"); + obj.index = JsonUtil.getInteger(jsonObj, "index"); return obj; } @@ -2140,11 +2109,15 @@ public Timestamp getLastChargedAt() { } public static ChargedItems fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static ChargedItems fromJson(JsonObject jsonObj) { ChargedItems obj = new ChargedItems(); - obj.itemPriceId = JsonUtil.getString(json, "item_price_id"); + obj.itemPriceId = JsonUtil.getString(jsonObj, "item_price_id"); - obj.lastChargedAt = JsonUtil.getTimestamp(json, "last_charged_at"); + obj.lastChargedAt = JsonUtil.getTimestamp(jsonObj, "last_charged_at"); return obj; } @@ -2200,15 +2173,19 @@ public String getCouponCode() { } public static Coupons fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Coupons fromJson(JsonObject jsonObj) { Coupons obj = new Coupons(); - obj.couponId = JsonUtil.getString(json, "coupon_id"); + obj.couponId = JsonUtil.getString(jsonObj, "coupon_id"); - obj.applyTill = JsonUtil.getTimestamp(json, "apply_till"); + obj.applyTill = JsonUtil.getTimestamp(jsonObj, "apply_till"); - obj.appliedCount = JsonUtil.getInteger(json, "applied_count"); + obj.appliedCount = JsonUtil.getInteger(jsonObj, "applied_count"); - obj.couponCode = JsonUtil.getString(json, "coupon_code"); + obj.couponCode = JsonUtil.getString(jsonObj, "coupon_code"); return obj; } @@ -2352,36 +2329,40 @@ public static ValidationStatus fromString(String value) { } public static ShippingAddress fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static ShippingAddress fromJson(JsonObject jsonObj) { ShippingAddress obj = new ShippingAddress(); - obj.firstName = JsonUtil.getString(json, "first_name"); + obj.firstName = JsonUtil.getString(jsonObj, "first_name"); - obj.lastName = JsonUtil.getString(json, "last_name"); + obj.lastName = JsonUtil.getString(jsonObj, "last_name"); - obj.email = JsonUtil.getString(json, "email"); + obj.email = JsonUtil.getString(jsonObj, "email"); - obj.company = JsonUtil.getString(json, "company"); + obj.company = JsonUtil.getString(jsonObj, "company"); - obj.phone = JsonUtil.getString(json, "phone"); + obj.phone = JsonUtil.getString(jsonObj, "phone"); - obj.line1 = JsonUtil.getString(json, "line1"); + obj.line1 = JsonUtil.getString(jsonObj, "line1"); - obj.line2 = JsonUtil.getString(json, "line2"); + obj.line2 = JsonUtil.getString(jsonObj, "line2"); - obj.line3 = JsonUtil.getString(json, "line3"); + obj.line3 = JsonUtil.getString(jsonObj, "line3"); - obj.city = JsonUtil.getString(json, "city"); + obj.city = JsonUtil.getString(jsonObj, "city"); - obj.stateCode = JsonUtil.getString(json, "state_code"); + obj.stateCode = JsonUtil.getString(jsonObj, "state_code"); - obj.state = JsonUtil.getString(json, "state"); + obj.state = JsonUtil.getString(jsonObj, "state"); - obj.country = JsonUtil.getString(json, "country"); + obj.country = JsonUtil.getString(jsonObj, "country"); - obj.zip = JsonUtil.getString(json, "zip"); + obj.zip = JsonUtil.getString(jsonObj, "zip"); obj.validationStatus = - ValidationStatus.fromString(JsonUtil.getString(json, "validation_status")); + ValidationStatus.fromString(JsonUtil.getString(jsonObj, "validation_status")); return obj; } @@ -2693,38 +2674,43 @@ public static NotifyReferralSystem fromString(String value) { } public static ReferralInfo fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static ReferralInfo fromJson(JsonObject jsonObj) { ReferralInfo obj = new ReferralInfo(); - obj.referralCode = JsonUtil.getString(json, "referral_code"); + obj.referralCode = JsonUtil.getString(jsonObj, "referral_code"); - obj.couponCode = JsonUtil.getString(json, "coupon_code"); + obj.couponCode = JsonUtil.getString(jsonObj, "coupon_code"); - obj.referrerId = JsonUtil.getString(json, "referrer_id"); + obj.referrerId = JsonUtil.getString(jsonObj, "referrer_id"); - obj.externalReferenceId = JsonUtil.getString(json, "external_reference_id"); + obj.externalReferenceId = JsonUtil.getString(jsonObj, "external_reference_id"); - obj.rewardStatus = RewardStatus.fromString(JsonUtil.getString(json, "reward_status")); + obj.rewardStatus = RewardStatus.fromString(JsonUtil.getString(jsonObj, "reward_status")); - obj.referralSystem = ReferralSystem.fromString(JsonUtil.getString(json, "referral_system")); + obj.referralSystem = + ReferralSystem.fromString(JsonUtil.getString(jsonObj, "referral_system")); - obj.accountId = JsonUtil.getString(json, "account_id"); + obj.accountId = JsonUtil.getString(jsonObj, "account_id"); - obj.campaignId = JsonUtil.getString(json, "campaign_id"); + obj.campaignId = JsonUtil.getString(jsonObj, "campaign_id"); - obj.externalCampaignId = JsonUtil.getString(json, "external_campaign_id"); + obj.externalCampaignId = JsonUtil.getString(jsonObj, "external_campaign_id"); obj.friendOfferType = - FriendOfferType.fromString(JsonUtil.getString(json, "friend_offer_type")); + FriendOfferType.fromString(JsonUtil.getString(jsonObj, "friend_offer_type")); obj.referrerRewardType = - ReferrerRewardType.fromString(JsonUtil.getString(json, "referrer_reward_type")); + ReferrerRewardType.fromString(JsonUtil.getString(jsonObj, "referrer_reward_type")); obj.notifyReferralSystem = - NotifyReferralSystem.fromString(JsonUtil.getString(json, "notify_referral_system")); + NotifyReferralSystem.fromString(JsonUtil.getString(jsonObj, "notify_referral_system")); - obj.destinationUrl = JsonUtil.getString(json, "destination_url"); + obj.destinationUrl = JsonUtil.getString(jsonObj, "destination_url"); - obj.postPurchaseWidgetEnabled = JsonUtil.getBoolean(json, "post_purchase_widget_enabled"); + obj.postPurchaseWidgetEnabled = JsonUtil.getBoolean(jsonObj, "post_purchase_widget_enabled"); return obj; } @@ -2820,11 +2806,15 @@ public Long getMaxRefundableCreditsUsage() { } public static BillingOverride fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static BillingOverride fromJson(JsonObject jsonObj) { BillingOverride obj = new BillingOverride(); - obj.maxExcessPaymentUsage = JsonUtil.getLong(json, "max_excess_payment_usage"); + obj.maxExcessPaymentUsage = JsonUtil.getLong(jsonObj, "max_excess_payment_usage"); - obj.maxRefundableCreditsUsage = JsonUtil.getLong(json, "max_refundable_credits_usage"); + obj.maxRefundableCreditsUsage = JsonUtil.getLong(jsonObj, "max_refundable_credits_usage"); return obj; } @@ -2984,32 +2974,37 @@ public static ActionAtTermEnd fromString(String value) { } public static ContractTerm fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static ContractTerm fromJson(JsonObject jsonObj) { ContractTerm obj = new ContractTerm(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.status = Status.fromString(JsonUtil.getString(json, "status")); + obj.status = Status.fromString(JsonUtil.getString(jsonObj, "status")); - obj.contractStart = JsonUtil.getTimestamp(json, "contract_start"); + obj.contractStart = JsonUtil.getTimestamp(jsonObj, "contract_start"); - obj.contractEnd = JsonUtil.getTimestamp(json, "contract_end"); + obj.contractEnd = JsonUtil.getTimestamp(jsonObj, "contract_end"); - obj.billingCycle = JsonUtil.getInteger(json, "billing_cycle"); + obj.billingCycle = JsonUtil.getInteger(jsonObj, "billing_cycle"); obj.actionAtTermEnd = - ActionAtTermEnd.fromString(JsonUtil.getString(json, "action_at_term_end")); + ActionAtTermEnd.fromString(JsonUtil.getString(jsonObj, "action_at_term_end")); - obj.totalContractValue = JsonUtil.getLong(json, "total_contract_value"); + obj.totalContractValue = JsonUtil.getLong(jsonObj, "total_contract_value"); - obj.totalContractValueBeforeTax = JsonUtil.getLong(json, "total_contract_value_before_tax"); + obj.totalContractValueBeforeTax = + JsonUtil.getLong(jsonObj, "total_contract_value_before_tax"); - obj.cancellationCutoffPeriod = JsonUtil.getInteger(json, "cancellation_cutoff_period"); + obj.cancellationCutoffPeriod = JsonUtil.getInteger(jsonObj, "cancellation_cutoff_period"); - obj.createdAt = JsonUtil.getTimestamp(json, "created_at"); + obj.createdAt = JsonUtil.getTimestamp(jsonObj, "created_at"); - obj.subscriptionId = JsonUtil.getString(json, "subscription_id"); + obj.subscriptionId = JsonUtil.getString(jsonObj, "subscription_id"); - obj.remainingBillingCycles = JsonUtil.getInteger(json, "remaining_billing_cycles"); + obj.remainingBillingCycles = JsonUtil.getInteger(jsonObj, "remaining_billing_cycles"); return obj; } @@ -3297,43 +3292,47 @@ public static ApplyOn fromString(String value) { } public static Discounts fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Discounts fromJson(JsonObject jsonObj) { Discounts obj = new Discounts(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.invoiceName = JsonUtil.getString(json, "invoice_name"); + obj.invoiceName = JsonUtil.getString(jsonObj, "invoice_name"); - obj.type = Type.fromString(JsonUtil.getString(json, "type")); + obj.type = Type.fromString(JsonUtil.getString(jsonObj, "type")); - obj.percentage = JsonUtil.getDouble(json, "percentage"); + obj.percentage = JsonUtil.getDouble(jsonObj, "percentage"); - obj.amount = JsonUtil.getLong(json, "amount"); + obj.amount = JsonUtil.getLong(jsonObj, "amount"); - obj.quantity = JsonUtil.getInteger(json, "quantity"); + obj.quantity = JsonUtil.getInteger(jsonObj, "quantity"); - obj.currencyCode = JsonUtil.getString(json, "currency_code"); + obj.currencyCode = JsonUtil.getString(jsonObj, "currency_code"); - obj.durationType = DurationType.fromString(JsonUtil.getString(json, "duration_type")); + obj.durationType = DurationType.fromString(JsonUtil.getString(jsonObj, "duration_type")); - obj.period = JsonUtil.getInteger(json, "period"); + obj.period = JsonUtil.getInteger(jsonObj, "period"); - obj.periodUnit = PeriodUnit.fromString(JsonUtil.getString(json, "period_unit")); + obj.periodUnit = PeriodUnit.fromString(JsonUtil.getString(jsonObj, "period_unit")); - obj.includedInMrr = JsonUtil.getBoolean(json, "included_in_mrr"); + obj.includedInMrr = JsonUtil.getBoolean(jsonObj, "included_in_mrr"); - obj.applyOn = ApplyOn.fromString(JsonUtil.getString(json, "apply_on")); + obj.applyOn = ApplyOn.fromString(JsonUtil.getString(jsonObj, "apply_on")); - obj.itemPriceId = JsonUtil.getString(json, "item_price_id"); + obj.itemPriceId = JsonUtil.getString(jsonObj, "item_price_id"); - obj.createdAt = JsonUtil.getTimestamp(json, "created_at"); + obj.createdAt = JsonUtil.getTimestamp(jsonObj, "created_at"); - obj.applyTill = JsonUtil.getTimestamp(json, "apply_till"); + obj.applyTill = JsonUtil.getTimestamp(jsonObj, "apply_till"); - obj.appliedCount = JsonUtil.getInteger(json, "applied_count"); + obj.appliedCount = JsonUtil.getInteger(jsonObj, "applied_count"); - obj.couponId = JsonUtil.getString(json, "coupon_id"); + obj.couponId = JsonUtil.getString(jsonObj, "coupon_id"); - obj.index = JsonUtil.getInteger(json, "index"); + obj.index = JsonUtil.getInteger(jsonObj, "index"); return obj; } @@ -3515,27 +3514,31 @@ public static ProrationType fromString(String value) { } public static Addons fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Addons fromJson(JsonObject jsonObj) { Addons obj = new Addons(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.quantity = JsonUtil.getInteger(json, "quantity"); + obj.quantity = JsonUtil.getInteger(jsonObj, "quantity"); - obj.unitPrice = JsonUtil.getLong(json, "unit_price"); + obj.unitPrice = JsonUtil.getLong(jsonObj, "unit_price"); - obj.amount = JsonUtil.getLong(json, "amount"); + obj.amount = JsonUtil.getLong(jsonObj, "amount"); - obj.trialEnd = JsonUtil.getTimestamp(json, "trial_end"); + obj.trialEnd = JsonUtil.getTimestamp(jsonObj, "trial_end"); - obj.remainingBillingCycles = JsonUtil.getInteger(json, "remaining_billing_cycles"); + obj.remainingBillingCycles = JsonUtil.getInteger(jsonObj, "remaining_billing_cycles"); - obj.quantityInDecimal = JsonUtil.getString(json, "quantity_in_decimal"); + obj.quantityInDecimal = JsonUtil.getString(jsonObj, "quantity_in_decimal"); - obj.unitPriceInDecimal = JsonUtil.getString(json, "unit_price_in_decimal"); + obj.unitPriceInDecimal = JsonUtil.getString(jsonObj, "unit_price_in_decimal"); - obj.amountInDecimal = JsonUtil.getString(json, "amount_in_decimal"); + obj.amountInDecimal = JsonUtil.getString(jsonObj, "amount_in_decimal"); - obj.prorationType = ProrationType.fromString(JsonUtil.getString(json, "proration_type")); + obj.prorationType = ProrationType.fromString(JsonUtil.getString(jsonObj, "proration_type")); return obj; } @@ -3615,11 +3618,15 @@ public Timestamp getLastChargedAt() { } public static ChargedEventBasedAddons fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static ChargedEventBasedAddons fromJson(JsonObject jsonObj) { ChargedEventBasedAddons obj = new ChargedEventBasedAddons(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.lastChargedAt = JsonUtil.getTimestamp(json, "last_charged_at"); + obj.lastChargedAt = JsonUtil.getTimestamp(jsonObj, "last_charged_at"); return obj; } @@ -3725,23 +3732,27 @@ public static OnEvent fromString(String value) { } public static EventBasedAddons fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static EventBasedAddons fromJson(JsonObject jsonObj) { EventBasedAddons obj = new EventBasedAddons(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.quantity = JsonUtil.getInteger(json, "quantity"); + obj.quantity = JsonUtil.getInteger(jsonObj, "quantity"); - obj.unitPrice = JsonUtil.getLong(json, "unit_price"); + obj.unitPrice = JsonUtil.getLong(jsonObj, "unit_price"); - obj.servicePeriodInDays = JsonUtil.getInteger(json, "service_period_in_days"); + obj.servicePeriodInDays = JsonUtil.getInteger(jsonObj, "service_period_in_days"); - obj.onEvent = OnEvent.fromString(JsonUtil.getString(json, "on_event")); + obj.onEvent = OnEvent.fromString(JsonUtil.getString(jsonObj, "on_event")); - obj.chargeOnce = JsonUtil.getBoolean(json, "charge_once"); + obj.chargeOnce = JsonUtil.getBoolean(jsonObj, "charge_once"); - obj.quantityInDecimal = JsonUtil.getString(json, "quantity_in_decimal"); + obj.quantityInDecimal = JsonUtil.getString(jsonObj, "quantity_in_decimal"); - obj.unitPriceInDecimal = JsonUtil.getString(json, "unit_price_in_decimal"); + obj.unitPriceInDecimal = JsonUtil.getString(jsonObj, "unit_price_in_decimal"); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/subscription/responses/ContractTermsForSubscriptionResponse.java b/src/main/java/com/chargebee/v4/models/subscription/responses/ContractTermsForSubscriptionResponse.java index 58709218..60cdd847 100644 --- a/src/main/java/com/chargebee/v4/models/subscription/responses/ContractTermsForSubscriptionResponse.java +++ b/src/main/java/com/chargebee/v4/models/subscription/responses/ContractTermsForSubscriptionResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.exceptions.ChargebeeException; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; import com.chargebee.v4.services.SubscriptionService; import com.chargebee.v4.models.subscription.params.ContractTermsForSubscriptionParams; @@ -51,13 +52,14 @@ private ContractTermsForSubscriptionResponse( */ public static ContractTermsForSubscriptionResponse fromJson(String json) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(SubscriptionContractTermsForSubscriptionItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "list"), + SubscriptionContractTermsForSubscriptionItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new ContractTermsForSubscriptionResponse(list, nextOffset, null, null, null, null); } catch (Exception e) { @@ -77,13 +79,14 @@ public static ContractTermsForSubscriptionResponse fromJson( String subscriptionId, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(SubscriptionContractTermsForSubscriptionItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "list"), + SubscriptionContractTermsForSubscriptionItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new ContractTermsForSubscriptionResponse( list, nextOffset, subscriptionId, service, originalParams, httpResponse); @@ -192,12 +195,16 @@ public ContractTerm getContractTerm() { } public static SubscriptionContractTermsForSubscriptionItem fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static SubscriptionContractTermsForSubscriptionItem fromJson(JsonObject jsonObj) { SubscriptionContractTermsForSubscriptionItem item = new SubscriptionContractTermsForSubscriptionItem(); - String __contractTermJson = JsonUtil.getObject(json, "contract_term"); - if (__contractTermJson != null) { - item.contractTerm = ContractTerm.fromJson(__contractTermJson); + JsonObject __contractTermObj = JsonUtil.getJsonObject(jsonObj, "contract_term"); + if (__contractTermObj != null) { + item.contractTerm = ContractTerm.fromJson(__contractTermObj); } return item; diff --git a/src/main/java/com/chargebee/v4/models/subscription/responses/ImportSubscriptionResponse.java b/src/main/java/com/chargebee/v4/models/subscription/responses/ImportSubscriptionResponse.java index db35a537..ce8f0141 100644 --- a/src/main/java/com/chargebee/v4/models/subscription/responses/ImportSubscriptionResponse.java +++ b/src/main/java/com/chargebee/v4/models/subscription/responses/ImportSubscriptionResponse.java @@ -10,6 +10,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -45,26 +46,27 @@ public static ImportSubscriptionResponse fromJson(String json) { /** Parse JSON response into ImportSubscriptionResponse object with HTTP response. */ public static ImportSubscriptionResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __subscriptionJson = JsonUtil.getObject(json, "subscription"); - if (__subscriptionJson != null) { - builder.subscription(Subscription.fromJson(__subscriptionJson)); + JsonObject __subscriptionObj = JsonUtil.getJsonObject(jsonObj, "subscription"); + if (__subscriptionObj != null) { + builder.subscription(Subscription.fromJson(__subscriptionObj)); } - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - builder.customer(Customer.fromJson(__customerJson)); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + builder.customer(Customer.fromJson(__customerObj)); } - String __cardJson = JsonUtil.getObject(json, "card"); - if (__cardJson != null) { - builder.card(Card.fromJson(__cardJson)); + JsonObject __cardObj = JsonUtil.getJsonObject(jsonObj, "card"); + if (__cardObj != null) { + builder.card(Card.fromJson(__cardObj)); } - String __invoiceJson = JsonUtil.getObject(json, "invoice"); - if (__invoiceJson != null) { - builder.invoice(Invoice.fromJson(__invoiceJson)); + JsonObject __invoiceObj = JsonUtil.getJsonObject(jsonObj, "invoice"); + if (__invoiceObj != null) { + builder.invoice(Invoice.fromJson(__invoiceObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionAddChargeAtTermEndResponse.java b/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionAddChargeAtTermEndResponse.java index 5694dea5..fea4860b 100644 --- a/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionAddChargeAtTermEndResponse.java +++ b/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionAddChargeAtTermEndResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -28,11 +29,12 @@ public static SubscriptionAddChargeAtTermEndResponse fromJson(String json) { public static SubscriptionAddChargeAtTermEndResponse fromJson( String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __estimateJson = JsonUtil.getObject(json, "estimate"); - if (__estimateJson != null) { - builder.estimate(Estimate.fromJson(__estimateJson)); + JsonObject __estimateObj = JsonUtil.getJsonObject(jsonObj, "estimate"); + if (__estimateObj != null) { + builder.estimate(Estimate.fromJson(__estimateObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionCancelForItemsResponse.java b/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionCancelForItemsResponse.java index 4230d155..9427b523 100644 --- a/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionCancelForItemsResponse.java +++ b/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionCancelForItemsResponse.java @@ -16,6 +16,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -59,37 +60,35 @@ public static SubscriptionCancelForItemsResponse fromJson(String json) { /** Parse JSON response into SubscriptionCancelForItemsResponse object with HTTP response. */ public static SubscriptionCancelForItemsResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __subscriptionJson = JsonUtil.getObject(json, "subscription"); - if (__subscriptionJson != null) { - builder.subscription(Subscription.fromJson(__subscriptionJson)); + JsonObject __subscriptionObj = JsonUtil.getJsonObject(jsonObj, "subscription"); + if (__subscriptionObj != null) { + builder.subscription(Subscription.fromJson(__subscriptionObj)); } - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - builder.customer(Customer.fromJson(__customerJson)); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + builder.customer(Customer.fromJson(__customerObj)); } - String __cardJson = JsonUtil.getObject(json, "card"); - if (__cardJson != null) { - builder.card(Card.fromJson(__cardJson)); + JsonObject __cardObj = JsonUtil.getJsonObject(jsonObj, "card"); + if (__cardObj != null) { + builder.card(Card.fromJson(__cardObj)); } - String __invoiceJson = JsonUtil.getObject(json, "invoice"); - if (__invoiceJson != null) { - builder.invoice(Invoice.fromJson(__invoiceJson)); + JsonObject __invoiceObj = JsonUtil.getJsonObject(jsonObj, "invoice"); + if (__invoiceObj != null) { + builder.invoice(Invoice.fromJson(__invoiceObj)); } builder.unbilledCharges( - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "unbilled_charges")).stream() - .map(UnbilledCharge::fromJson) - .collect(java.util.stream.Collectors.toList())); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "unbilled_charges"), UnbilledCharge::fromJson)); builder.creditNotes( - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "credit_notes")).stream() - .map(CreditNote::fromJson) - .collect(java.util.stream.Collectors.toList())); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "credit_notes"), CreditNote::fromJson)); builder.httpResponse(httpResponse); return builder.build(); diff --git a/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionCancelResponse.java b/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionCancelResponse.java index b194e5f3..e12fa84b 100644 --- a/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionCancelResponse.java +++ b/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionCancelResponse.java @@ -16,6 +16,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -59,37 +60,35 @@ public static SubscriptionCancelResponse fromJson(String json) { /** Parse JSON response into SubscriptionCancelResponse object with HTTP response. */ public static SubscriptionCancelResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __subscriptionJson = JsonUtil.getObject(json, "subscription"); - if (__subscriptionJson != null) { - builder.subscription(Subscription.fromJson(__subscriptionJson)); + JsonObject __subscriptionObj = JsonUtil.getJsonObject(jsonObj, "subscription"); + if (__subscriptionObj != null) { + builder.subscription(Subscription.fromJson(__subscriptionObj)); } - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - builder.customer(Customer.fromJson(__customerJson)); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + builder.customer(Customer.fromJson(__customerObj)); } - String __cardJson = JsonUtil.getObject(json, "card"); - if (__cardJson != null) { - builder.card(Card.fromJson(__cardJson)); + JsonObject __cardObj = JsonUtil.getJsonObject(jsonObj, "card"); + if (__cardObj != null) { + builder.card(Card.fromJson(__cardObj)); } - String __invoiceJson = JsonUtil.getObject(json, "invoice"); - if (__invoiceJson != null) { - builder.invoice(Invoice.fromJson(__invoiceJson)); + JsonObject __invoiceObj = JsonUtil.getJsonObject(jsonObj, "invoice"); + if (__invoiceObj != null) { + builder.invoice(Invoice.fromJson(__invoiceObj)); } builder.unbilledCharges( - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "unbilled_charges")).stream() - .map(UnbilledCharge::fromJson) - .collect(java.util.stream.Collectors.toList())); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "unbilled_charges"), UnbilledCharge::fromJson)); builder.creditNotes( - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "credit_notes")).stream() - .map(CreditNote::fromJson) - .collect(java.util.stream.Collectors.toList())); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "credit_notes"), CreditNote::fromJson)); builder.httpResponse(httpResponse); return builder.build(); diff --git a/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionChangeTermEndResponse.java b/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionChangeTermEndResponse.java index 01dd2842..38a44112 100644 --- a/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionChangeTermEndResponse.java +++ b/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionChangeTermEndResponse.java @@ -16,6 +16,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -59,37 +60,35 @@ public static SubscriptionChangeTermEndResponse fromJson(String json) { /** Parse JSON response into SubscriptionChangeTermEndResponse object with HTTP response. */ public static SubscriptionChangeTermEndResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __subscriptionJson = JsonUtil.getObject(json, "subscription"); - if (__subscriptionJson != null) { - builder.subscription(Subscription.fromJson(__subscriptionJson)); + JsonObject __subscriptionObj = JsonUtil.getJsonObject(jsonObj, "subscription"); + if (__subscriptionObj != null) { + builder.subscription(Subscription.fromJson(__subscriptionObj)); } - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - builder.customer(Customer.fromJson(__customerJson)); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + builder.customer(Customer.fromJson(__customerObj)); } - String __cardJson = JsonUtil.getObject(json, "card"); - if (__cardJson != null) { - builder.card(Card.fromJson(__cardJson)); + JsonObject __cardObj = JsonUtil.getJsonObject(jsonObj, "card"); + if (__cardObj != null) { + builder.card(Card.fromJson(__cardObj)); } - String __invoiceJson = JsonUtil.getObject(json, "invoice"); - if (__invoiceJson != null) { - builder.invoice(Invoice.fromJson(__invoiceJson)); + JsonObject __invoiceObj = JsonUtil.getJsonObject(jsonObj, "invoice"); + if (__invoiceObj != null) { + builder.invoice(Invoice.fromJson(__invoiceObj)); } builder.unbilledCharges( - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "unbilled_charges")).stream() - .map(UnbilledCharge::fromJson) - .collect(java.util.stream.Collectors.toList())); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "unbilled_charges"), UnbilledCharge::fromJson)); builder.creditNotes( - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "credit_notes")).stream() - .map(CreditNote::fromJson) - .collect(java.util.stream.Collectors.toList())); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "credit_notes"), CreditNote::fromJson)); builder.httpResponse(httpResponse); return builder.build(); diff --git a/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionChargeAddonAtTermEndResponse.java b/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionChargeAddonAtTermEndResponse.java index 386fb442..b78dcd63 100644 --- a/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionChargeAddonAtTermEndResponse.java +++ b/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionChargeAddonAtTermEndResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -30,11 +31,12 @@ public static SubscriptionChargeAddonAtTermEndResponse fromJson(String json) { public static SubscriptionChargeAddonAtTermEndResponse fromJson( String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __estimateJson = JsonUtil.getObject(json, "estimate"); - if (__estimateJson != null) { - builder.estimate(Estimate.fromJson(__estimateJson)); + JsonObject __estimateObj = JsonUtil.getJsonObject(jsonObj, "estimate"); + if (__estimateObj != null) { + builder.estimate(Estimate.fromJson(__estimateObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionChargeFutureRenewalsResponse.java b/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionChargeFutureRenewalsResponse.java index 9f8c8ec6..b456b8c4 100644 --- a/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionChargeFutureRenewalsResponse.java +++ b/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionChargeFutureRenewalsResponse.java @@ -14,6 +14,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -56,32 +57,33 @@ public static SubscriptionChargeFutureRenewalsResponse fromJson(String json) { public static SubscriptionChargeFutureRenewalsResponse fromJson( String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __subscriptionJson = JsonUtil.getObject(json, "subscription"); - if (__subscriptionJson != null) { - builder.subscription(Subscription.fromJson(__subscriptionJson)); + JsonObject __subscriptionObj = JsonUtil.getJsonObject(jsonObj, "subscription"); + if (__subscriptionObj != null) { + builder.subscription(Subscription.fromJson(__subscriptionObj)); } - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - builder.customer(Customer.fromJson(__customerJson)); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + builder.customer(Customer.fromJson(__customerObj)); } - String __cardJson = JsonUtil.getObject(json, "card"); - if (__cardJson != null) { - builder.card(Card.fromJson(__cardJson)); + JsonObject __cardObj = JsonUtil.getJsonObject(jsonObj, "card"); + if (__cardObj != null) { + builder.card(Card.fromJson(__cardObj)); } - String __invoiceJson = JsonUtil.getObject(json, "invoice"); - if (__invoiceJson != null) { - builder.invoice(Invoice.fromJson(__invoiceJson)); + JsonObject __invoiceObj = JsonUtil.getJsonObject(jsonObj, "invoice"); + if (__invoiceObj != null) { + builder.invoice(Invoice.fromJson(__invoiceObj)); } builder.advanceInvoiceSchedules( - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "advance_invoice_schedules")).stream() - .map(AdvanceInvoiceSchedule::fromJson) - .collect(java.util.stream.Collectors.toList())); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "advance_invoice_schedules"), + AdvanceInvoiceSchedule::fromJson)); builder.httpResponse(httpResponse); return builder.build(); diff --git a/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionCreateForCustomerResponse.java b/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionCreateForCustomerResponse.java index 34dc17a6..46ca3c2e 100644 --- a/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionCreateForCustomerResponse.java +++ b/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionCreateForCustomerResponse.java @@ -14,6 +14,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -53,32 +54,32 @@ public static SubscriptionCreateForCustomerResponse fromJson(String json) { /** Parse JSON response into SubscriptionCreateForCustomerResponse object with HTTP response. */ public static SubscriptionCreateForCustomerResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __subscriptionJson = JsonUtil.getObject(json, "subscription"); - if (__subscriptionJson != null) { - builder.subscription(Subscription.fromJson(__subscriptionJson)); + JsonObject __subscriptionObj = JsonUtil.getJsonObject(jsonObj, "subscription"); + if (__subscriptionObj != null) { + builder.subscription(Subscription.fromJson(__subscriptionObj)); } - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - builder.customer(Customer.fromJson(__customerJson)); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + builder.customer(Customer.fromJson(__customerObj)); } - String __cardJson = JsonUtil.getObject(json, "card"); - if (__cardJson != null) { - builder.card(Card.fromJson(__cardJson)); + JsonObject __cardObj = JsonUtil.getJsonObject(jsonObj, "card"); + if (__cardObj != null) { + builder.card(Card.fromJson(__cardObj)); } - String __invoiceJson = JsonUtil.getObject(json, "invoice"); - if (__invoiceJson != null) { - builder.invoice(Invoice.fromJson(__invoiceJson)); + JsonObject __invoiceObj = JsonUtil.getJsonObject(jsonObj, "invoice"); + if (__invoiceObj != null) { + builder.invoice(Invoice.fromJson(__invoiceObj)); } builder.unbilledCharges( - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "unbilled_charges")).stream() - .map(UnbilledCharge::fromJson) - .collect(java.util.stream.Collectors.toList())); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "unbilled_charges"), UnbilledCharge::fromJson)); builder.httpResponse(httpResponse); return builder.build(); diff --git a/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionCreateResponse.java b/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionCreateResponse.java index 56d4fbab..c742a0f1 100644 --- a/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionCreateResponse.java +++ b/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionCreateResponse.java @@ -14,6 +14,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -53,32 +54,32 @@ public static SubscriptionCreateResponse fromJson(String json) { /** Parse JSON response into SubscriptionCreateResponse object with HTTP response. */ public static SubscriptionCreateResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __subscriptionJson = JsonUtil.getObject(json, "subscription"); - if (__subscriptionJson != null) { - builder.subscription(Subscription.fromJson(__subscriptionJson)); + JsonObject __subscriptionObj = JsonUtil.getJsonObject(jsonObj, "subscription"); + if (__subscriptionObj != null) { + builder.subscription(Subscription.fromJson(__subscriptionObj)); } - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - builder.customer(Customer.fromJson(__customerJson)); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + builder.customer(Customer.fromJson(__customerObj)); } - String __cardJson = JsonUtil.getObject(json, "card"); - if (__cardJson != null) { - builder.card(Card.fromJson(__cardJson)); + JsonObject __cardObj = JsonUtil.getJsonObject(jsonObj, "card"); + if (__cardObj != null) { + builder.card(Card.fromJson(__cardObj)); } - String __invoiceJson = JsonUtil.getObject(json, "invoice"); - if (__invoiceJson != null) { - builder.invoice(Invoice.fromJson(__invoiceJson)); + JsonObject __invoiceObj = JsonUtil.getJsonObject(jsonObj, "invoice"); + if (__invoiceObj != null) { + builder.invoice(Invoice.fromJson(__invoiceObj)); } builder.unbilledCharges( - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "unbilled_charges")).stream() - .map(UnbilledCharge::fromJson) - .collect(java.util.stream.Collectors.toList())); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "unbilled_charges"), UnbilledCharge::fromJson)); builder.httpResponse(httpResponse); return builder.build(); diff --git a/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionCreateWithItemsResponse.java b/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionCreateWithItemsResponse.java index 4e468af5..4cd97cec 100644 --- a/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionCreateWithItemsResponse.java +++ b/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionCreateWithItemsResponse.java @@ -14,6 +14,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -53,32 +54,32 @@ public static SubscriptionCreateWithItemsResponse fromJson(String json) { /** Parse JSON response into SubscriptionCreateWithItemsResponse object with HTTP response. */ public static SubscriptionCreateWithItemsResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __subscriptionJson = JsonUtil.getObject(json, "subscription"); - if (__subscriptionJson != null) { - builder.subscription(Subscription.fromJson(__subscriptionJson)); + JsonObject __subscriptionObj = JsonUtil.getJsonObject(jsonObj, "subscription"); + if (__subscriptionObj != null) { + builder.subscription(Subscription.fromJson(__subscriptionObj)); } - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - builder.customer(Customer.fromJson(__customerJson)); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + builder.customer(Customer.fromJson(__customerObj)); } - String __cardJson = JsonUtil.getObject(json, "card"); - if (__cardJson != null) { - builder.card(Card.fromJson(__cardJson)); + JsonObject __cardObj = JsonUtil.getJsonObject(jsonObj, "card"); + if (__cardObj != null) { + builder.card(Card.fromJson(__cardObj)); } - String __invoiceJson = JsonUtil.getObject(json, "invoice"); - if (__invoiceJson != null) { - builder.invoice(Invoice.fromJson(__invoiceJson)); + JsonObject __invoiceObj = JsonUtil.getJsonObject(jsonObj, "invoice"); + if (__invoiceObj != null) { + builder.invoice(Invoice.fromJson(__invoiceObj)); } builder.unbilledCharges( - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "unbilled_charges")).stream() - .map(UnbilledCharge::fromJson) - .collect(java.util.stream.Collectors.toList())); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "unbilled_charges"), UnbilledCharge::fromJson)); builder.httpResponse(httpResponse); return builder.build(); diff --git a/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionDeleteResponse.java b/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionDeleteResponse.java index 6d018149..ad2140a8 100644 --- a/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionDeleteResponse.java +++ b/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionDeleteResponse.java @@ -8,6 +8,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -39,21 +40,22 @@ public static SubscriptionDeleteResponse fromJson(String json) { /** Parse JSON response into SubscriptionDeleteResponse object with HTTP response. */ public static SubscriptionDeleteResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __subscriptionJson = JsonUtil.getObject(json, "subscription"); - if (__subscriptionJson != null) { - builder.subscription(Subscription.fromJson(__subscriptionJson)); + JsonObject __subscriptionObj = JsonUtil.getJsonObject(jsonObj, "subscription"); + if (__subscriptionObj != null) { + builder.subscription(Subscription.fromJson(__subscriptionObj)); } - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - builder.customer(Customer.fromJson(__customerJson)); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + builder.customer(Customer.fromJson(__customerObj)); } - String __cardJson = JsonUtil.getObject(json, "card"); - if (__cardJson != null) { - builder.card(Card.fromJson(__cardJson)); + JsonObject __cardObj = JsonUtil.getJsonObject(jsonObj, "card"); + if (__cardObj != null) { + builder.card(Card.fromJson(__cardObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionEditAdvanceInvoiceScheduleResponse.java b/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionEditAdvanceInvoiceScheduleResponse.java index ee6eff60..3e5e8206 100644 --- a/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionEditAdvanceInvoiceScheduleResponse.java +++ b/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionEditAdvanceInvoiceScheduleResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -33,12 +34,13 @@ public static SubscriptionEditAdvanceInvoiceScheduleResponse fromJson(String jso public static SubscriptionEditAdvanceInvoiceScheduleResponse fromJson( String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); builder.advanceInvoiceSchedules( - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "advance_invoice_schedules")).stream() - .map(AdvanceInvoiceSchedule::fromJson) - .collect(java.util.stream.Collectors.toList())); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "advance_invoice_schedules"), + AdvanceInvoiceSchedule::fromJson)); builder.httpResponse(httpResponse); return builder.build(); diff --git a/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionImportContractTermResponse.java b/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionImportContractTermResponse.java index 86984429..a40d8452 100644 --- a/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionImportContractTermResponse.java +++ b/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionImportContractTermResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -28,11 +29,12 @@ public static SubscriptionImportContractTermResponse fromJson(String json) { public static SubscriptionImportContractTermResponse fromJson( String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __contractTermJson = JsonUtil.getObject(json, "contract_term"); - if (__contractTermJson != null) { - builder.contractTerm(ContractTerm.fromJson(__contractTermJson)); + JsonObject __contractTermObj = JsonUtil.getJsonObject(jsonObj, "contract_term"); + if (__contractTermObj != null) { + builder.contractTerm(ContractTerm.fromJson(__contractTermObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionImportForCustomerResponse.java b/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionImportForCustomerResponse.java index 10b7fde1..e4514e4b 100644 --- a/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionImportForCustomerResponse.java +++ b/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionImportForCustomerResponse.java @@ -10,6 +10,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -45,26 +46,27 @@ public static SubscriptionImportForCustomerResponse fromJson(String json) { /** Parse JSON response into SubscriptionImportForCustomerResponse object with HTTP response. */ public static SubscriptionImportForCustomerResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __subscriptionJson = JsonUtil.getObject(json, "subscription"); - if (__subscriptionJson != null) { - builder.subscription(Subscription.fromJson(__subscriptionJson)); + JsonObject __subscriptionObj = JsonUtil.getJsonObject(jsonObj, "subscription"); + if (__subscriptionObj != null) { + builder.subscription(Subscription.fromJson(__subscriptionObj)); } - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - builder.customer(Customer.fromJson(__customerJson)); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + builder.customer(Customer.fromJson(__customerObj)); } - String __cardJson = JsonUtil.getObject(json, "card"); - if (__cardJson != null) { - builder.card(Card.fromJson(__cardJson)); + JsonObject __cardObj = JsonUtil.getJsonObject(jsonObj, "card"); + if (__cardObj != null) { + builder.card(Card.fromJson(__cardObj)); } - String __invoiceJson = JsonUtil.getObject(json, "invoice"); - if (__invoiceJson != null) { - builder.invoice(Invoice.fromJson(__invoiceJson)); + JsonObject __invoiceObj = JsonUtil.getJsonObject(jsonObj, "invoice"); + if (__invoiceObj != null) { + builder.invoice(Invoice.fromJson(__invoiceObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionImportForItemsResponse.java b/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionImportForItemsResponse.java index 27ed1854..f059f55f 100644 --- a/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionImportForItemsResponse.java +++ b/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionImportForItemsResponse.java @@ -10,6 +10,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -45,26 +46,27 @@ public static SubscriptionImportForItemsResponse fromJson(String json) { /** Parse JSON response into SubscriptionImportForItemsResponse object with HTTP response. */ public static SubscriptionImportForItemsResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __subscriptionJson = JsonUtil.getObject(json, "subscription"); - if (__subscriptionJson != null) { - builder.subscription(Subscription.fromJson(__subscriptionJson)); + JsonObject __subscriptionObj = JsonUtil.getJsonObject(jsonObj, "subscription"); + if (__subscriptionObj != null) { + builder.subscription(Subscription.fromJson(__subscriptionObj)); } - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - builder.customer(Customer.fromJson(__customerJson)); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + builder.customer(Customer.fromJson(__customerObj)); } - String __cardJson = JsonUtil.getObject(json, "card"); - if (__cardJson != null) { - builder.card(Card.fromJson(__cardJson)); + JsonObject __cardObj = JsonUtil.getJsonObject(jsonObj, "card"); + if (__cardObj != null) { + builder.card(Card.fromJson(__cardObj)); } - String __invoiceJson = JsonUtil.getObject(json, "invoice"); - if (__invoiceJson != null) { - builder.invoice(Invoice.fromJson(__invoiceJson)); + JsonObject __invoiceObj = JsonUtil.getJsonObject(jsonObj, "invoice"); + if (__invoiceObj != null) { + builder.invoice(Invoice.fromJson(__invoiceObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionImportUnbilledChargesResponse.java b/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionImportUnbilledChargesResponse.java index 25ea9c94..4bf67098 100644 --- a/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionImportUnbilledChargesResponse.java +++ b/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionImportUnbilledChargesResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -32,12 +33,12 @@ public static SubscriptionImportUnbilledChargesResponse fromJson(String json) { public static SubscriptionImportUnbilledChargesResponse fromJson( String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); builder.unbilledCharges( - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "unbilled_charges")).stream() - .map(UnbilledCharge::fromJson) - .collect(java.util.stream.Collectors.toList())); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "unbilled_charges"), UnbilledCharge::fromJson)); builder.httpResponse(httpResponse); return builder.build(); diff --git a/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionListDiscountsResponse.java b/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionListDiscountsResponse.java index 31185aad..1c59f774 100644 --- a/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionListDiscountsResponse.java +++ b/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionListDiscountsResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.exceptions.ChargebeeException; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; import com.chargebee.v4.services.SubscriptionService; import com.chargebee.v4.models.subscription.params.SubscriptionListDiscountsParams; @@ -50,13 +51,13 @@ private SubscriptionListDiscountsResponse( */ public static SubscriptionListDiscountsResponse fromJson(String json) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(SubscriptionListDiscountsItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "list"), SubscriptionListDiscountsItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new SubscriptionListDiscountsResponse(list, nextOffset, null, null, null, null); } catch (Exception e) { @@ -75,13 +76,13 @@ public static SubscriptionListDiscountsResponse fromJson( String subscriptionId, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(SubscriptionListDiscountsItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "list"), SubscriptionListDiscountsItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new SubscriptionListDiscountsResponse( list, nextOffset, subscriptionId, service, originalParams, httpResponse); @@ -189,11 +190,15 @@ public Discount getDiscount() { } public static SubscriptionListDiscountsItem fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static SubscriptionListDiscountsItem fromJson(JsonObject jsonObj) { SubscriptionListDiscountsItem item = new SubscriptionListDiscountsItem(); - String __discountJson = JsonUtil.getObject(json, "discount"); - if (__discountJson != null) { - item.discount = Discount.fromJson(__discountJson); + JsonObject __discountObj = JsonUtil.getJsonObject(jsonObj, "discount"); + if (__discountObj != null) { + item.discount = Discount.fromJson(__discountObj); } return item; diff --git a/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionListResponse.java b/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionListResponse.java index 3bfcc823..5780c3f7 100644 --- a/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionListResponse.java +++ b/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionListResponse.java @@ -10,6 +10,7 @@ import com.chargebee.v4.exceptions.ChargebeeException; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; import com.chargebee.v4.services.SubscriptionService; import com.chargebee.v4.models.subscription.params.SubscriptionListParams; @@ -47,13 +48,12 @@ private SubscriptionListResponse( */ public static SubscriptionListResponse fromJson(String json) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(SubscriptionListItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "list"), SubscriptionListItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new SubscriptionListResponse(list, nextOffset, null, null, null); } catch (Exception e) { @@ -71,13 +71,12 @@ public static SubscriptionListResponse fromJson( SubscriptionListParams originalParams, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(SubscriptionListItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "list"), SubscriptionListItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new SubscriptionListResponse(list, nextOffset, service, originalParams, httpResponse); } catch (Exception e) { @@ -189,21 +188,25 @@ public Card getCard() { } public static SubscriptionListItem fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static SubscriptionListItem fromJson(JsonObject jsonObj) { SubscriptionListItem item = new SubscriptionListItem(); - String __subscriptionJson = JsonUtil.getObject(json, "subscription"); - if (__subscriptionJson != null) { - item.subscription = Subscription.fromJson(__subscriptionJson); + JsonObject __subscriptionObj = JsonUtil.getJsonObject(jsonObj, "subscription"); + if (__subscriptionObj != null) { + item.subscription = Subscription.fromJson(__subscriptionObj); } - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - item.customer = Customer.fromJson(__customerJson); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + item.customer = Customer.fromJson(__customerObj); } - String __cardJson = JsonUtil.getObject(json, "card"); - if (__cardJson != null) { - item.card = Card.fromJson(__cardJson); + JsonObject __cardObj = JsonUtil.getJsonObject(jsonObj, "card"); + if (__cardObj != null) { + item.card = Card.fromJson(__cardObj); } return item; diff --git a/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionMoveResponse.java b/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionMoveResponse.java index 8a43c82d..66147ac9 100644 --- a/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionMoveResponse.java +++ b/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionMoveResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static SubscriptionMoveResponse fromJson(String json) { /** Parse JSON response into SubscriptionMoveResponse object with HTTP response. */ public static SubscriptionMoveResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __subscriptionJson = JsonUtil.getObject(json, "subscription"); - if (__subscriptionJson != null) { - builder.subscription(Subscription.fromJson(__subscriptionJson)); + JsonObject __subscriptionObj = JsonUtil.getJsonObject(jsonObj, "subscription"); + if (__subscriptionObj != null) { + builder.subscription(Subscription.fromJson(__subscriptionObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionOverrideBillingProfileResponse.java b/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionOverrideBillingProfileResponse.java index c03d8466..eb74d552 100644 --- a/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionOverrideBillingProfileResponse.java +++ b/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionOverrideBillingProfileResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -36,16 +37,17 @@ public static SubscriptionOverrideBillingProfileResponse fromJson(String json) { public static SubscriptionOverrideBillingProfileResponse fromJson( String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __subscriptionJson = JsonUtil.getObject(json, "subscription"); - if (__subscriptionJson != null) { - builder.subscription(Subscription.fromJson(__subscriptionJson)); + JsonObject __subscriptionObj = JsonUtil.getJsonObject(jsonObj, "subscription"); + if (__subscriptionObj != null) { + builder.subscription(Subscription.fromJson(__subscriptionObj)); } - String __paymentSourceJson = JsonUtil.getObject(json, "payment_source"); - if (__paymentSourceJson != null) { - builder.paymentSource(PaymentSource.fromJson(__paymentSourceJson)); + JsonObject __paymentSourceObj = JsonUtil.getJsonObject(jsonObj, "payment_source"); + if (__paymentSourceObj != null) { + builder.paymentSource(PaymentSource.fromJson(__paymentSourceObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionPauseResponse.java b/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionPauseResponse.java index 06796a80..6f1ac974 100644 --- a/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionPauseResponse.java +++ b/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionPauseResponse.java @@ -16,6 +16,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -59,37 +60,35 @@ public static SubscriptionPauseResponse fromJson(String json) { /** Parse JSON response into SubscriptionPauseResponse object with HTTP response. */ public static SubscriptionPauseResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __subscriptionJson = JsonUtil.getObject(json, "subscription"); - if (__subscriptionJson != null) { - builder.subscription(Subscription.fromJson(__subscriptionJson)); + JsonObject __subscriptionObj = JsonUtil.getJsonObject(jsonObj, "subscription"); + if (__subscriptionObj != null) { + builder.subscription(Subscription.fromJson(__subscriptionObj)); } - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - builder.customer(Customer.fromJson(__customerJson)); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + builder.customer(Customer.fromJson(__customerObj)); } - String __cardJson = JsonUtil.getObject(json, "card"); - if (__cardJson != null) { - builder.card(Card.fromJson(__cardJson)); + JsonObject __cardObj = JsonUtil.getJsonObject(jsonObj, "card"); + if (__cardObj != null) { + builder.card(Card.fromJson(__cardObj)); } - String __invoiceJson = JsonUtil.getObject(json, "invoice"); - if (__invoiceJson != null) { - builder.invoice(Invoice.fromJson(__invoiceJson)); + JsonObject __invoiceObj = JsonUtil.getJsonObject(jsonObj, "invoice"); + if (__invoiceObj != null) { + builder.invoice(Invoice.fromJson(__invoiceObj)); } builder.unbilledCharges( - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "unbilled_charges")).stream() - .map(UnbilledCharge::fromJson) - .collect(java.util.stream.Collectors.toList())); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "unbilled_charges"), UnbilledCharge::fromJson)); builder.creditNotes( - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "credit_notes")).stream() - .map(CreditNote::fromJson) - .collect(java.util.stream.Collectors.toList())); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "credit_notes"), CreditNote::fromJson)); builder.httpResponse(httpResponse); return builder.build(); diff --git a/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionReactivateResponse.java b/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionReactivateResponse.java index 4813aa92..8d25b40a 100644 --- a/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionReactivateResponse.java +++ b/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionReactivateResponse.java @@ -14,6 +14,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -53,32 +54,32 @@ public static SubscriptionReactivateResponse fromJson(String json) { /** Parse JSON response into SubscriptionReactivateResponse object with HTTP response. */ public static SubscriptionReactivateResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __subscriptionJson = JsonUtil.getObject(json, "subscription"); - if (__subscriptionJson != null) { - builder.subscription(Subscription.fromJson(__subscriptionJson)); + JsonObject __subscriptionObj = JsonUtil.getJsonObject(jsonObj, "subscription"); + if (__subscriptionObj != null) { + builder.subscription(Subscription.fromJson(__subscriptionObj)); } - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - builder.customer(Customer.fromJson(__customerJson)); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + builder.customer(Customer.fromJson(__customerObj)); } - String __cardJson = JsonUtil.getObject(json, "card"); - if (__cardJson != null) { - builder.card(Card.fromJson(__cardJson)); + JsonObject __cardObj = JsonUtil.getJsonObject(jsonObj, "card"); + if (__cardObj != null) { + builder.card(Card.fromJson(__cardObj)); } - String __invoiceJson = JsonUtil.getObject(json, "invoice"); - if (__invoiceJson != null) { - builder.invoice(Invoice.fromJson(__invoiceJson)); + JsonObject __invoiceObj = JsonUtil.getJsonObject(jsonObj, "invoice"); + if (__invoiceObj != null) { + builder.invoice(Invoice.fromJson(__invoiceObj)); } builder.unbilledCharges( - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "unbilled_charges")).stream() - .map(UnbilledCharge::fromJson) - .collect(java.util.stream.Collectors.toList())); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "unbilled_charges"), UnbilledCharge::fromJson)); builder.httpResponse(httpResponse); return builder.build(); diff --git a/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionRegenerateInvoiceResponse.java b/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionRegenerateInvoiceResponse.java index 7efc2988..8b26992a 100644 --- a/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionRegenerateInvoiceResponse.java +++ b/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionRegenerateInvoiceResponse.java @@ -8,6 +8,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -35,17 +36,17 @@ public static SubscriptionRegenerateInvoiceResponse fromJson(String json) { /** Parse JSON response into SubscriptionRegenerateInvoiceResponse object with HTTP response. */ public static SubscriptionRegenerateInvoiceResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __invoiceJson = JsonUtil.getObject(json, "invoice"); - if (__invoiceJson != null) { - builder.invoice(Invoice.fromJson(__invoiceJson)); + JsonObject __invoiceObj = JsonUtil.getJsonObject(jsonObj, "invoice"); + if (__invoiceObj != null) { + builder.invoice(Invoice.fromJson(__invoiceObj)); } builder.unbilledCharges( - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "unbilled_charges")).stream() - .map(UnbilledCharge::fromJson) - .collect(java.util.stream.Collectors.toList())); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "unbilled_charges"), UnbilledCharge::fromJson)); builder.httpResponse(httpResponse); return builder.build(); diff --git a/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionRemoveAdvanceInvoiceScheduleResponse.java b/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionRemoveAdvanceInvoiceScheduleResponse.java index a2785312..7275f15f 100644 --- a/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionRemoveAdvanceInvoiceScheduleResponse.java +++ b/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionRemoveAdvanceInvoiceScheduleResponse.java @@ -8,6 +8,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -39,17 +40,18 @@ public static SubscriptionRemoveAdvanceInvoiceScheduleResponse fromJson(String j public static SubscriptionRemoveAdvanceInvoiceScheduleResponse fromJson( String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __subscriptionJson = JsonUtil.getObject(json, "subscription"); - if (__subscriptionJson != null) { - builder.subscription(Subscription.fromJson(__subscriptionJson)); + JsonObject __subscriptionObj = JsonUtil.getJsonObject(jsonObj, "subscription"); + if (__subscriptionObj != null) { + builder.subscription(Subscription.fromJson(__subscriptionObj)); } builder.advanceInvoiceSchedules( - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "advance_invoice_schedules")).stream() - .map(AdvanceInvoiceSchedule::fromJson) - .collect(java.util.stream.Collectors.toList())); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "advance_invoice_schedules"), + AdvanceInvoiceSchedule::fromJson)); builder.httpResponse(httpResponse); return builder.build(); diff --git a/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionRemoveCouponsResponse.java b/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionRemoveCouponsResponse.java index 0181f0ae..83139260 100644 --- a/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionRemoveCouponsResponse.java +++ b/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionRemoveCouponsResponse.java @@ -8,6 +8,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -39,21 +40,22 @@ public static SubscriptionRemoveCouponsResponse fromJson(String json) { /** Parse JSON response into SubscriptionRemoveCouponsResponse object with HTTP response. */ public static SubscriptionRemoveCouponsResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __subscriptionJson = JsonUtil.getObject(json, "subscription"); - if (__subscriptionJson != null) { - builder.subscription(Subscription.fromJson(__subscriptionJson)); + JsonObject __subscriptionObj = JsonUtil.getJsonObject(jsonObj, "subscription"); + if (__subscriptionObj != null) { + builder.subscription(Subscription.fromJson(__subscriptionObj)); } - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - builder.customer(Customer.fromJson(__customerJson)); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + builder.customer(Customer.fromJson(__customerObj)); } - String __cardJson = JsonUtil.getObject(json, "card"); - if (__cardJson != null) { - builder.card(Card.fromJson(__cardJson)); + JsonObject __cardObj = JsonUtil.getJsonObject(jsonObj, "card"); + if (__cardObj != null) { + builder.card(Card.fromJson(__cardObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionRemoveScheduledCancellationResponse.java b/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionRemoveScheduledCancellationResponse.java index 681eb02a..a1e07965 100644 --- a/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionRemoveScheduledCancellationResponse.java +++ b/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionRemoveScheduledCancellationResponse.java @@ -8,6 +8,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -43,21 +44,22 @@ public static SubscriptionRemoveScheduledCancellationResponse fromJson(String js public static SubscriptionRemoveScheduledCancellationResponse fromJson( String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __subscriptionJson = JsonUtil.getObject(json, "subscription"); - if (__subscriptionJson != null) { - builder.subscription(Subscription.fromJson(__subscriptionJson)); + JsonObject __subscriptionObj = JsonUtil.getJsonObject(jsonObj, "subscription"); + if (__subscriptionObj != null) { + builder.subscription(Subscription.fromJson(__subscriptionObj)); } - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - builder.customer(Customer.fromJson(__customerJson)); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + builder.customer(Customer.fromJson(__customerObj)); } - String __cardJson = JsonUtil.getObject(json, "card"); - if (__cardJson != null) { - builder.card(Card.fromJson(__cardJson)); + JsonObject __cardObj = JsonUtil.getJsonObject(jsonObj, "card"); + if (__cardObj != null) { + builder.card(Card.fromJson(__cardObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionRemoveScheduledChangesResponse.java b/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionRemoveScheduledChangesResponse.java index da1da870..092cf168 100644 --- a/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionRemoveScheduledChangesResponse.java +++ b/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionRemoveScheduledChangesResponse.java @@ -12,6 +12,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -50,27 +51,26 @@ public static SubscriptionRemoveScheduledChangesResponse fromJson(String json) { public static SubscriptionRemoveScheduledChangesResponse fromJson( String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __subscriptionJson = JsonUtil.getObject(json, "subscription"); - if (__subscriptionJson != null) { - builder.subscription(Subscription.fromJson(__subscriptionJson)); + JsonObject __subscriptionObj = JsonUtil.getJsonObject(jsonObj, "subscription"); + if (__subscriptionObj != null) { + builder.subscription(Subscription.fromJson(__subscriptionObj)); } - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - builder.customer(Customer.fromJson(__customerJson)); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + builder.customer(Customer.fromJson(__customerObj)); } - String __cardJson = JsonUtil.getObject(json, "card"); - if (__cardJson != null) { - builder.card(Card.fromJson(__cardJson)); + JsonObject __cardObj = JsonUtil.getJsonObject(jsonObj, "card"); + if (__cardObj != null) { + builder.card(Card.fromJson(__cardObj)); } builder.creditNotes( - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "credit_notes")).stream() - .map(CreditNote::fromJson) - .collect(java.util.stream.Collectors.toList())); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "credit_notes"), CreditNote::fromJson)); builder.httpResponse(httpResponse); return builder.build(); diff --git a/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionRemoveScheduledPauseResponse.java b/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionRemoveScheduledPauseResponse.java index a3881eb5..06e727c8 100644 --- a/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionRemoveScheduledPauseResponse.java +++ b/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionRemoveScheduledPauseResponse.java @@ -8,6 +8,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -42,21 +43,22 @@ public static SubscriptionRemoveScheduledPauseResponse fromJson(String json) { public static SubscriptionRemoveScheduledPauseResponse fromJson( String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __subscriptionJson = JsonUtil.getObject(json, "subscription"); - if (__subscriptionJson != null) { - builder.subscription(Subscription.fromJson(__subscriptionJson)); + JsonObject __subscriptionObj = JsonUtil.getJsonObject(jsonObj, "subscription"); + if (__subscriptionObj != null) { + builder.subscription(Subscription.fromJson(__subscriptionObj)); } - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - builder.customer(Customer.fromJson(__customerJson)); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + builder.customer(Customer.fromJson(__customerObj)); } - String __cardJson = JsonUtil.getObject(json, "card"); - if (__cardJson != null) { - builder.card(Card.fromJson(__cardJson)); + JsonObject __cardObj = JsonUtil.getJsonObject(jsonObj, "card"); + if (__cardObj != null) { + builder.card(Card.fromJson(__cardObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionRemoveScheduledResumptionResponse.java b/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionRemoveScheduledResumptionResponse.java index c96c3cf2..67305980 100644 --- a/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionRemoveScheduledResumptionResponse.java +++ b/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionRemoveScheduledResumptionResponse.java @@ -8,6 +8,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -43,21 +44,22 @@ public static SubscriptionRemoveScheduledResumptionResponse fromJson(String json public static SubscriptionRemoveScheduledResumptionResponse fromJson( String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __subscriptionJson = JsonUtil.getObject(json, "subscription"); - if (__subscriptionJson != null) { - builder.subscription(Subscription.fromJson(__subscriptionJson)); + JsonObject __subscriptionObj = JsonUtil.getJsonObject(jsonObj, "subscription"); + if (__subscriptionObj != null) { + builder.subscription(Subscription.fromJson(__subscriptionObj)); } - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - builder.customer(Customer.fromJson(__customerJson)); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + builder.customer(Customer.fromJson(__customerObj)); } - String __cardJson = JsonUtil.getObject(json, "card"); - if (__cardJson != null) { - builder.card(Card.fromJson(__cardJson)); + JsonObject __cardObj = JsonUtil.getJsonObject(jsonObj, "card"); + if (__cardObj != null) { + builder.card(Card.fromJson(__cardObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionResumeResponse.java b/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionResumeResponse.java index 14334337..4055c13b 100644 --- a/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionResumeResponse.java +++ b/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionResumeResponse.java @@ -14,6 +14,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -53,32 +54,32 @@ public static SubscriptionResumeResponse fromJson(String json) { /** Parse JSON response into SubscriptionResumeResponse object with HTTP response. */ public static SubscriptionResumeResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __subscriptionJson = JsonUtil.getObject(json, "subscription"); - if (__subscriptionJson != null) { - builder.subscription(Subscription.fromJson(__subscriptionJson)); + JsonObject __subscriptionObj = JsonUtil.getJsonObject(jsonObj, "subscription"); + if (__subscriptionObj != null) { + builder.subscription(Subscription.fromJson(__subscriptionObj)); } - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - builder.customer(Customer.fromJson(__customerJson)); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + builder.customer(Customer.fromJson(__customerObj)); } - String __cardJson = JsonUtil.getObject(json, "card"); - if (__cardJson != null) { - builder.card(Card.fromJson(__cardJson)); + JsonObject __cardObj = JsonUtil.getJsonObject(jsonObj, "card"); + if (__cardObj != null) { + builder.card(Card.fromJson(__cardObj)); } - String __invoiceJson = JsonUtil.getObject(json, "invoice"); - if (__invoiceJson != null) { - builder.invoice(Invoice.fromJson(__invoiceJson)); + JsonObject __invoiceObj = JsonUtil.getJsonObject(jsonObj, "invoice"); + if (__invoiceObj != null) { + builder.invoice(Invoice.fromJson(__invoiceObj)); } builder.unbilledCharges( - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "unbilled_charges")).stream() - .map(UnbilledCharge::fromJson) - .collect(java.util.stream.Collectors.toList())); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "unbilled_charges"), UnbilledCharge::fromJson)); builder.httpResponse(httpResponse); return builder.build(); diff --git a/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionRetrieveAdvanceInvoiceScheduleResponse.java b/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionRetrieveAdvanceInvoiceScheduleResponse.java index 78f4dd67..f2ca77b8 100644 --- a/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionRetrieveAdvanceInvoiceScheduleResponse.java +++ b/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionRetrieveAdvanceInvoiceScheduleResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; import java.util.List; @@ -32,15 +33,13 @@ public static SubscriptionRetrieveAdvanceInvoiceScheduleResponse fromJson(String public static SubscriptionRetrieveAdvanceInvoiceScheduleResponse fromJson( String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __advanceInvoiceSchedulesJson = JsonUtil.getArray(json, "advance_invoice_schedules"); - if (__advanceInvoiceSchedulesJson != null) { - builder.advanceInvoiceSchedules( - JsonUtil.parseObjectArray(__advanceInvoiceSchedulesJson).stream() - .map(AdvanceInvoiceSchedule::fromJson) - .collect(java.util.stream.Collectors.toList())); - } + builder.advanceInvoiceSchedules( + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "advance_invoice_schedules"), + AdvanceInvoiceSchedule::fromJson)); builder.httpResponse(httpResponse); return builder.build(); diff --git a/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionRetrieveResponse.java b/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionRetrieveResponse.java index c64e4451..11f321a9 100644 --- a/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionRetrieveResponse.java +++ b/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionRetrieveResponse.java @@ -8,6 +8,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -39,21 +40,22 @@ public static SubscriptionRetrieveResponse fromJson(String json) { /** Parse JSON response into SubscriptionRetrieveResponse object with HTTP response. */ public static SubscriptionRetrieveResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __subscriptionJson = JsonUtil.getObject(json, "subscription"); - if (__subscriptionJson != null) { - builder.subscription(Subscription.fromJson(__subscriptionJson)); + JsonObject __subscriptionObj = JsonUtil.getJsonObject(jsonObj, "subscription"); + if (__subscriptionObj != null) { + builder.subscription(Subscription.fromJson(__subscriptionObj)); } - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - builder.customer(Customer.fromJson(__customerJson)); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + builder.customer(Customer.fromJson(__customerObj)); } - String __cardJson = JsonUtil.getObject(json, "card"); - if (__cardJson != null) { - builder.card(Card.fromJson(__cardJson)); + JsonObject __cardObj = JsonUtil.getJsonObject(jsonObj, "card"); + if (__cardObj != null) { + builder.card(Card.fromJson(__cardObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionRetrieveWithScheduledChangesResponse.java b/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionRetrieveWithScheduledChangesResponse.java index d14bc63d..8729358f 100644 --- a/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionRetrieveWithScheduledChangesResponse.java +++ b/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionRetrieveWithScheduledChangesResponse.java @@ -8,6 +8,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -43,21 +44,22 @@ public static SubscriptionRetrieveWithScheduledChangesResponse fromJson(String j public static SubscriptionRetrieveWithScheduledChangesResponse fromJson( String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __subscriptionJson = JsonUtil.getObject(json, "subscription"); - if (__subscriptionJson != null) { - builder.subscription(Subscription.fromJson(__subscriptionJson)); + JsonObject __subscriptionObj = JsonUtil.getJsonObject(jsonObj, "subscription"); + if (__subscriptionObj != null) { + builder.subscription(Subscription.fromJson(__subscriptionObj)); } - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - builder.customer(Customer.fromJson(__customerJson)); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + builder.customer(Customer.fromJson(__customerObj)); } - String __cardJson = JsonUtil.getObject(json, "card"); - if (__cardJson != null) { - builder.card(Card.fromJson(__cardJson)); + JsonObject __cardObj = JsonUtil.getJsonObject(jsonObj, "card"); + if (__cardObj != null) { + builder.card(Card.fromJson(__cardObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionUpdateForItemsResponse.java b/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionUpdateForItemsResponse.java index 88d99b74..b8353eca 100644 --- a/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionUpdateForItemsResponse.java +++ b/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionUpdateForItemsResponse.java @@ -16,6 +16,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -59,37 +60,35 @@ public static SubscriptionUpdateForItemsResponse fromJson(String json) { /** Parse JSON response into SubscriptionUpdateForItemsResponse object with HTTP response. */ public static SubscriptionUpdateForItemsResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __subscriptionJson = JsonUtil.getObject(json, "subscription"); - if (__subscriptionJson != null) { - builder.subscription(Subscription.fromJson(__subscriptionJson)); + JsonObject __subscriptionObj = JsonUtil.getJsonObject(jsonObj, "subscription"); + if (__subscriptionObj != null) { + builder.subscription(Subscription.fromJson(__subscriptionObj)); } - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - builder.customer(Customer.fromJson(__customerJson)); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + builder.customer(Customer.fromJson(__customerObj)); } - String __cardJson = JsonUtil.getObject(json, "card"); - if (__cardJson != null) { - builder.card(Card.fromJson(__cardJson)); + JsonObject __cardObj = JsonUtil.getJsonObject(jsonObj, "card"); + if (__cardObj != null) { + builder.card(Card.fromJson(__cardObj)); } - String __invoiceJson = JsonUtil.getObject(json, "invoice"); - if (__invoiceJson != null) { - builder.invoice(Invoice.fromJson(__invoiceJson)); + JsonObject __invoiceObj = JsonUtil.getJsonObject(jsonObj, "invoice"); + if (__invoiceObj != null) { + builder.invoice(Invoice.fromJson(__invoiceObj)); } builder.unbilledCharges( - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "unbilled_charges")).stream() - .map(UnbilledCharge::fromJson) - .collect(java.util.stream.Collectors.toList())); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "unbilled_charges"), UnbilledCharge::fromJson)); builder.creditNotes( - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "credit_notes")).stream() - .map(CreditNote::fromJson) - .collect(java.util.stream.Collectors.toList())); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "credit_notes"), CreditNote::fromJson)); builder.httpResponse(httpResponse); return builder.build(); diff --git a/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionUpdateResponse.java b/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionUpdateResponse.java index 23272a3d..0c2a447a 100644 --- a/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionUpdateResponse.java +++ b/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionUpdateResponse.java @@ -16,6 +16,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -59,37 +60,35 @@ public static SubscriptionUpdateResponse fromJson(String json) { /** Parse JSON response into SubscriptionUpdateResponse object with HTTP response. */ public static SubscriptionUpdateResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __subscriptionJson = JsonUtil.getObject(json, "subscription"); - if (__subscriptionJson != null) { - builder.subscription(Subscription.fromJson(__subscriptionJson)); + JsonObject __subscriptionObj = JsonUtil.getJsonObject(jsonObj, "subscription"); + if (__subscriptionObj != null) { + builder.subscription(Subscription.fromJson(__subscriptionObj)); } - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - builder.customer(Customer.fromJson(__customerJson)); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + builder.customer(Customer.fromJson(__customerObj)); } - String __cardJson = JsonUtil.getObject(json, "card"); - if (__cardJson != null) { - builder.card(Card.fromJson(__cardJson)); + JsonObject __cardObj = JsonUtil.getJsonObject(jsonObj, "card"); + if (__cardObj != null) { + builder.card(Card.fromJson(__cardObj)); } - String __invoiceJson = JsonUtil.getObject(json, "invoice"); - if (__invoiceJson != null) { - builder.invoice(Invoice.fromJson(__invoiceJson)); + JsonObject __invoiceObj = JsonUtil.getJsonObject(jsonObj, "invoice"); + if (__invoiceObj != null) { + builder.invoice(Invoice.fromJson(__invoiceObj)); } builder.unbilledCharges( - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "unbilled_charges")).stream() - .map(UnbilledCharge::fromJson) - .collect(java.util.stream.Collectors.toList())); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "unbilled_charges"), UnbilledCharge::fromJson)); builder.creditNotes( - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "credit_notes")).stream() - .map(CreditNote::fromJson) - .collect(java.util.stream.Collectors.toList())); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "credit_notes"), CreditNote::fromJson)); builder.httpResponse(httpResponse); return builder.build(); diff --git a/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionsForCustomerResponse.java b/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionsForCustomerResponse.java index 086e2316..00187161 100644 --- a/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionsForCustomerResponse.java +++ b/src/main/java/com/chargebee/v4/models/subscription/responses/SubscriptionsForCustomerResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.exceptions.ChargebeeException; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; import com.chargebee.v4.services.SubscriptionService; import com.chargebee.v4.models.subscription.params.SubscriptionsForCustomerParams; @@ -50,13 +51,14 @@ private SubscriptionsForCustomerResponse( */ public static SubscriptionsForCustomerResponse fromJson(String json) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(SubscriptionSubscriptionsForCustomerItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "list"), + SubscriptionSubscriptionsForCustomerItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new SubscriptionsForCustomerResponse(list, nextOffset, null, null, null, null); } catch (Exception e) { @@ -75,13 +77,14 @@ public static SubscriptionsForCustomerResponse fromJson( String customerId, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(SubscriptionSubscriptionsForCustomerItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "list"), + SubscriptionSubscriptionsForCustomerItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new SubscriptionsForCustomerResponse( list, nextOffset, customerId, service, originalParams, httpResponse); @@ -189,12 +192,16 @@ public Subscription getSubscription() { } public static SubscriptionSubscriptionsForCustomerItem fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static SubscriptionSubscriptionsForCustomerItem fromJson(JsonObject jsonObj) { SubscriptionSubscriptionsForCustomerItem item = new SubscriptionSubscriptionsForCustomerItem(); - String __subscriptionJson = JsonUtil.getObject(json, "subscription"); - if (__subscriptionJson != null) { - item.subscription = Subscription.fromJson(__subscriptionJson); + JsonObject __subscriptionObj = JsonUtil.getJsonObject(jsonObj, "subscription"); + if (__subscriptionObj != null) { + item.subscription = Subscription.fromJson(__subscriptionObj); } return item; diff --git a/src/main/java/com/chargebee/v4/models/subscriptionEntitlement/SubscriptionEntitlement.java b/src/main/java/com/chargebee/v4/models/subscriptionEntitlement/SubscriptionEntitlement.java index 7dc302c7..8ce96678 100644 --- a/src/main/java/com/chargebee/v4/models/subscriptionEntitlement/SubscriptionEntitlement.java +++ b/src/main/java/com/chargebee/v4/models/subscriptionEntitlement/SubscriptionEntitlement.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.subscriptionEntitlement; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import java.sql.Timestamp; public class SubscriptionEntitlement { @@ -111,35 +112,39 @@ public static ScheduleStatus fromString(String value) { } public static SubscriptionEntitlement fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static SubscriptionEntitlement fromJson(JsonObject jsonObj) { SubscriptionEntitlement obj = new SubscriptionEntitlement(); - obj.subscriptionId = JsonUtil.getString(json, "subscription_id"); + obj.subscriptionId = JsonUtil.getString(jsonObj, "subscription_id"); - obj.featureId = JsonUtil.getString(json, "feature_id"); + obj.featureId = JsonUtil.getString(jsonObj, "feature_id"); - obj.featureName = JsonUtil.getString(json, "feature_name"); + obj.featureName = JsonUtil.getString(jsonObj, "feature_name"); - obj.featureUnit = JsonUtil.getString(json, "feature_unit"); + obj.featureUnit = JsonUtil.getString(jsonObj, "feature_unit"); - obj.featureType = JsonUtil.getString(json, "feature_type"); + obj.featureType = JsonUtil.getString(jsonObj, "feature_type"); - obj.value = JsonUtil.getString(json, "value"); + obj.value = JsonUtil.getString(jsonObj, "value"); - obj.name = JsonUtil.getString(json, "name"); + obj.name = JsonUtil.getString(jsonObj, "name"); - obj.isOverridden = JsonUtil.getBoolean(json, "is_overridden"); + obj.isOverridden = JsonUtil.getBoolean(jsonObj, "is_overridden"); - obj.isEnabled = JsonUtil.getBoolean(json, "is_enabled"); + obj.isEnabled = JsonUtil.getBoolean(jsonObj, "is_enabled"); - obj.effectiveFrom = JsonUtil.getTimestamp(json, "effective_from"); + obj.effectiveFrom = JsonUtil.getTimestamp(jsonObj, "effective_from"); - obj.scheduleStatus = ScheduleStatus.fromString(JsonUtil.getString(json, "schedule_status")); + obj.scheduleStatus = ScheduleStatus.fromString(JsonUtil.getString(jsonObj, "schedule_status")); - obj.expiresAt = JsonUtil.getTimestamp(json, "expires_at"); + obj.expiresAt = JsonUtil.getTimestamp(jsonObj, "expires_at"); - String __componentsJson = JsonUtil.getObject(json, "components"); - if (__componentsJson != null) { - obj.components = Components.fromJson(__componentsJson); + JsonObject __componentsObj = JsonUtil.getJsonObject(jsonObj, "components"); + if (__componentsObj != null) { + obj.components = Components.fromJson(__componentsObj); } return obj; @@ -226,11 +231,16 @@ public EntitlementOverrides getEntitlementOverrides() { } public static Components fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Components fromJson(JsonObject jsonObj) { Components obj = new Components(); - String __entitlementOverridesJson = JsonUtil.getObject(json, "entitlement_overrides"); - if (__entitlementOverridesJson != null) { - obj.entitlementOverrides = EntitlementOverrides.fromJson(__entitlementOverridesJson); + JsonObject __entitlementOverridesObj = + JsonUtil.getJsonObject(jsonObj, "entitlement_overrides"); + if (__entitlementOverridesObj != null) { + obj.entitlementOverrides = EntitlementOverrides.fromJson(__entitlementOverridesObj); } return obj; @@ -270,11 +280,15 @@ public String getName() { } public static EntitlementOverrides fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static EntitlementOverrides fromJson(JsonObject jsonObj) { EntitlementOverrides obj = new EntitlementOverrides(); - obj.value = JsonUtil.getString(json, "value"); + obj.value = JsonUtil.getString(jsonObj, "value"); - obj.name = JsonUtil.getString(json, "name"); + obj.name = JsonUtil.getString(jsonObj, "name"); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/subscriptionEntitlement/responses/SetSubscriptionEntitlementAvailabilityResponse.java b/src/main/java/com/chargebee/v4/models/subscriptionEntitlement/responses/SetSubscriptionEntitlementAvailabilityResponse.java index 89975a1c..337497b6 100644 --- a/src/main/java/com/chargebee/v4/models/subscriptionEntitlement/responses/SetSubscriptionEntitlementAvailabilityResponse.java +++ b/src/main/java/com/chargebee/v4/models/subscriptionEntitlement/responses/SetSubscriptionEntitlementAvailabilityResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -33,12 +34,12 @@ public static SetSubscriptionEntitlementAvailabilityResponse fromJson(String jso public static SetSubscriptionEntitlementAvailabilityResponse fromJson( String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); builder.list( - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(SubscriptionEntitlement::fromJson) - .collect(java.util.stream.Collectors.toList())); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "list"), SubscriptionEntitlement::fromJson)); builder.httpResponse(httpResponse); return builder.build(); diff --git a/src/main/java/com/chargebee/v4/models/subscriptionEntitlement/responses/SubscriptionEntitlementsForSubscriptionResponse.java b/src/main/java/com/chargebee/v4/models/subscriptionEntitlement/responses/SubscriptionEntitlementsForSubscriptionResponse.java index 5e0a75be..b5db0cce 100644 --- a/src/main/java/com/chargebee/v4/models/subscriptionEntitlement/responses/SubscriptionEntitlementsForSubscriptionResponse.java +++ b/src/main/java/com/chargebee/v4/models/subscriptionEntitlement/responses/SubscriptionEntitlementsForSubscriptionResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.exceptions.ChargebeeException; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; import com.chargebee.v4.services.SubscriptionEntitlementService; import com.chargebee.v4.models.subscriptionEntitlement.params.SubscriptionEntitlementsForSubscriptionParams; @@ -51,13 +52,14 @@ private SubscriptionEntitlementsForSubscriptionResponse( */ public static SubscriptionEntitlementsForSubscriptionResponse fromJson(String json) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(SubscriptionEntitlementSubscriptionEntitlementsForSubscriptionItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "list"), + SubscriptionEntitlementSubscriptionEntitlementsForSubscriptionItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new SubscriptionEntitlementsForSubscriptionResponse( list, nextOffset, null, null, null, null); @@ -78,13 +80,14 @@ public static SubscriptionEntitlementsForSubscriptionResponse fromJson( String subscriptionId, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(SubscriptionEntitlementSubscriptionEntitlementsForSubscriptionItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "list"), + SubscriptionEntitlementSubscriptionEntitlementsForSubscriptionItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new SubscriptionEntitlementsForSubscriptionResponse( list, nextOffset, subscriptionId, service, originalParams, httpResponse); @@ -195,13 +198,19 @@ public SubscriptionEntitlement getSubscriptionEntitlement() { public static SubscriptionEntitlementSubscriptionEntitlementsForSubscriptionItem fromJson( String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static SubscriptionEntitlementSubscriptionEntitlementsForSubscriptionItem fromJson( + JsonObject jsonObj) { SubscriptionEntitlementSubscriptionEntitlementsForSubscriptionItem item = new SubscriptionEntitlementSubscriptionEntitlementsForSubscriptionItem(); - String __subscriptionEntitlementJson = JsonUtil.getObject(json, "subscription_entitlement"); - if (__subscriptionEntitlementJson != null) { + JsonObject __subscriptionEntitlementObj = + JsonUtil.getJsonObject(jsonObj, "subscription_entitlement"); + if (__subscriptionEntitlementObj != null) { item.subscriptionEntitlement = - SubscriptionEntitlement.fromJson(__subscriptionEntitlementJson); + SubscriptionEntitlement.fromJson(__subscriptionEntitlementObj); } return item; diff --git a/src/main/java/com/chargebee/v4/models/subscriptionEntitlementsCreatedDetail/SubscriptionEntitlementsCreatedDetail.java b/src/main/java/com/chargebee/v4/models/subscriptionEntitlementsCreatedDetail/SubscriptionEntitlementsCreatedDetail.java index 81c30566..63e0ec49 100644 --- a/src/main/java/com/chargebee/v4/models/subscriptionEntitlementsCreatedDetail/SubscriptionEntitlementsCreatedDetail.java +++ b/src/main/java/com/chargebee/v4/models/subscriptionEntitlementsCreatedDetail/SubscriptionEntitlementsCreatedDetail.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.subscriptionEntitlementsCreatedDetail; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; public class SubscriptionEntitlementsCreatedDetail { @@ -23,11 +24,15 @@ public Boolean getHasNext() { } public static SubscriptionEntitlementsCreatedDetail fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static SubscriptionEntitlementsCreatedDetail fromJson(JsonObject jsonObj) { SubscriptionEntitlementsCreatedDetail obj = new SubscriptionEntitlementsCreatedDetail(); - obj.subscriptionId = JsonUtil.getString(json, "subscription_id"); + obj.subscriptionId = JsonUtil.getString(jsonObj, "subscription_id"); - obj.hasNext = JsonUtil.getBoolean(json, "has_next"); + obj.hasNext = JsonUtil.getBoolean(jsonObj, "has_next"); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/subscriptionEntitlementsUpdatedDetail/SubscriptionEntitlementsUpdatedDetail.java b/src/main/java/com/chargebee/v4/models/subscriptionEntitlementsUpdatedDetail/SubscriptionEntitlementsUpdatedDetail.java index 74cce52e..86f08026 100644 --- a/src/main/java/com/chargebee/v4/models/subscriptionEntitlementsUpdatedDetail/SubscriptionEntitlementsUpdatedDetail.java +++ b/src/main/java/com/chargebee/v4/models/subscriptionEntitlementsUpdatedDetail/SubscriptionEntitlementsUpdatedDetail.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.subscriptionEntitlementsUpdatedDetail; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; public class SubscriptionEntitlementsUpdatedDetail { @@ -23,11 +24,15 @@ public Boolean getHasNext() { } public static SubscriptionEntitlementsUpdatedDetail fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static SubscriptionEntitlementsUpdatedDetail fromJson(JsonObject jsonObj) { SubscriptionEntitlementsUpdatedDetail obj = new SubscriptionEntitlementsUpdatedDetail(); - obj.subscriptionId = JsonUtil.getString(json, "subscription_id"); + obj.subscriptionId = JsonUtil.getString(jsonObj, "subscription_id"); - obj.hasNext = JsonUtil.getBoolean(json, "has_next"); + obj.hasNext = JsonUtil.getBoolean(jsonObj, "has_next"); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/subscriptionEstimate/SubscriptionEstimate.java b/src/main/java/com/chargebee/v4/models/subscriptionEstimate/SubscriptionEstimate.java index 450baaca..a49614a4 100644 --- a/src/main/java/com/chargebee/v4/models/subscriptionEstimate/SubscriptionEstimate.java +++ b/src/main/java/com/chargebee/v4/models/subscriptionEstimate/SubscriptionEstimate.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.subscriptionEstimate; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import java.sql.Timestamp; public class SubscriptionEstimate { @@ -129,30 +130,34 @@ public static TrialEndAction fromString(String value) { } public static SubscriptionEstimate fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static SubscriptionEstimate fromJson(JsonObject jsonObj) { SubscriptionEstimate obj = new SubscriptionEstimate(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.currencyCode = JsonUtil.getString(json, "currency_code"); + obj.currencyCode = JsonUtil.getString(jsonObj, "currency_code"); - obj.status = Status.fromString(JsonUtil.getString(json, "status")); + obj.status = Status.fromString(JsonUtil.getString(jsonObj, "status")); - obj.trialEndAction = TrialEndAction.fromString(JsonUtil.getString(json, "trial_end_action")); + obj.trialEndAction = TrialEndAction.fromString(JsonUtil.getString(jsonObj, "trial_end_action")); - obj.nextBillingAt = JsonUtil.getTimestamp(json, "next_billing_at"); + obj.nextBillingAt = JsonUtil.getTimestamp(jsonObj, "next_billing_at"); - obj.pauseDate = JsonUtil.getTimestamp(json, "pause_date"); + obj.pauseDate = JsonUtil.getTimestamp(jsonObj, "pause_date"); - obj.resumeDate = JsonUtil.getTimestamp(json, "resume_date"); + obj.resumeDate = JsonUtil.getTimestamp(jsonObj, "resume_date"); - String __shippingAddressJson = JsonUtil.getObject(json, "shipping_address"); - if (__shippingAddressJson != null) { - obj.shippingAddress = ShippingAddress.fromJson(__shippingAddressJson); + JsonObject __shippingAddressObj = JsonUtil.getJsonObject(jsonObj, "shipping_address"); + if (__shippingAddressObj != null) { + obj.shippingAddress = ShippingAddress.fromJson(__shippingAddressObj); } - String __contractTermJson = JsonUtil.getObject(json, "contract_term"); - if (__contractTermJson != null) { - obj.contractTerm = ContractTerm.fromJson(__contractTermJson); + JsonObject __contractTermObj = JsonUtil.getJsonObject(jsonObj, "contract_term"); + if (__contractTermObj != null) { + obj.contractTerm = ContractTerm.fromJson(__contractTermObj); } return obj; @@ -320,36 +325,40 @@ public static ValidationStatus fromString(String value) { } public static ShippingAddress fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static ShippingAddress fromJson(JsonObject jsonObj) { ShippingAddress obj = new ShippingAddress(); - obj.firstName = JsonUtil.getString(json, "first_name"); + obj.firstName = JsonUtil.getString(jsonObj, "first_name"); - obj.lastName = JsonUtil.getString(json, "last_name"); + obj.lastName = JsonUtil.getString(jsonObj, "last_name"); - obj.email = JsonUtil.getString(json, "email"); + obj.email = JsonUtil.getString(jsonObj, "email"); - obj.company = JsonUtil.getString(json, "company"); + obj.company = JsonUtil.getString(jsonObj, "company"); - obj.phone = JsonUtil.getString(json, "phone"); + obj.phone = JsonUtil.getString(jsonObj, "phone"); - obj.line1 = JsonUtil.getString(json, "line1"); + obj.line1 = JsonUtil.getString(jsonObj, "line1"); - obj.line2 = JsonUtil.getString(json, "line2"); + obj.line2 = JsonUtil.getString(jsonObj, "line2"); - obj.line3 = JsonUtil.getString(json, "line3"); + obj.line3 = JsonUtil.getString(jsonObj, "line3"); - obj.city = JsonUtil.getString(json, "city"); + obj.city = JsonUtil.getString(jsonObj, "city"); - obj.stateCode = JsonUtil.getString(json, "state_code"); + obj.stateCode = JsonUtil.getString(jsonObj, "state_code"); - obj.state = JsonUtil.getString(json, "state"); + obj.state = JsonUtil.getString(jsonObj, "state"); - obj.country = JsonUtil.getString(json, "country"); + obj.country = JsonUtil.getString(jsonObj, "country"); - obj.zip = JsonUtil.getString(json, "zip"); + obj.zip = JsonUtil.getString(jsonObj, "zip"); obj.validationStatus = - ValidationStatus.fromString(JsonUtil.getString(json, "validation_status")); + ValidationStatus.fromString(JsonUtil.getString(jsonObj, "validation_status")); return obj; } @@ -559,32 +568,37 @@ public static ActionAtTermEnd fromString(String value) { } public static ContractTerm fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static ContractTerm fromJson(JsonObject jsonObj) { ContractTerm obj = new ContractTerm(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.status = Status.fromString(JsonUtil.getString(json, "status")); + obj.status = Status.fromString(JsonUtil.getString(jsonObj, "status")); - obj.contractStart = JsonUtil.getTimestamp(json, "contract_start"); + obj.contractStart = JsonUtil.getTimestamp(jsonObj, "contract_start"); - obj.contractEnd = JsonUtil.getTimestamp(json, "contract_end"); + obj.contractEnd = JsonUtil.getTimestamp(jsonObj, "contract_end"); - obj.billingCycle = JsonUtil.getInteger(json, "billing_cycle"); + obj.billingCycle = JsonUtil.getInteger(jsonObj, "billing_cycle"); obj.actionAtTermEnd = - ActionAtTermEnd.fromString(JsonUtil.getString(json, "action_at_term_end")); + ActionAtTermEnd.fromString(JsonUtil.getString(jsonObj, "action_at_term_end")); - obj.totalContractValue = JsonUtil.getLong(json, "total_contract_value"); + obj.totalContractValue = JsonUtil.getLong(jsonObj, "total_contract_value"); - obj.totalContractValueBeforeTax = JsonUtil.getLong(json, "total_contract_value_before_tax"); + obj.totalContractValueBeforeTax = + JsonUtil.getLong(jsonObj, "total_contract_value_before_tax"); - obj.cancellationCutoffPeriod = JsonUtil.getInteger(json, "cancellation_cutoff_period"); + obj.cancellationCutoffPeriod = JsonUtil.getInteger(jsonObj, "cancellation_cutoff_period"); - obj.createdAt = JsonUtil.getTimestamp(json, "created_at"); + obj.createdAt = JsonUtil.getTimestamp(jsonObj, "created_at"); - obj.subscriptionId = JsonUtil.getString(json, "subscription_id"); + obj.subscriptionId = JsonUtil.getString(jsonObj, "subscription_id"); - obj.remainingBillingCycles = JsonUtil.getInteger(json, "remaining_billing_cycles"); + obj.remainingBillingCycles = JsonUtil.getInteger(jsonObj, "remaining_billing_cycles"); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/subscriptionSetting/responses/SubscriptionSettingRetrieveResponse.java b/src/main/java/com/chargebee/v4/models/subscriptionSetting/responses/SubscriptionSettingRetrieveResponse.java index 3cd32ce0..e7e4f372 100644 --- a/src/main/java/com/chargebee/v4/models/subscriptionSetting/responses/SubscriptionSettingRetrieveResponse.java +++ b/src/main/java/com/chargebee/v4/models/subscriptionSetting/responses/SubscriptionSettingRetrieveResponse.java @@ -2,6 +2,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -25,9 +26,10 @@ public static SubscriptionSettingRetrieveResponse fromJson(String json) { /** Parse JSON response into SubscriptionSettingRetrieveResponse object with HTTP response. */ public static SubscriptionSettingRetrieveResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - builder.subscriptionSetting(JsonUtil.getObject(json, "subscription_setting")); + builder.subscriptionSetting(JsonUtil.getObject(jsonObj, "subscription_setting")); builder.httpResponse(httpResponse); return builder.build(); diff --git a/src/main/java/com/chargebee/v4/models/taxWithheld/TaxWithheld.java b/src/main/java/com/chargebee/v4/models/taxWithheld/TaxWithheld.java index 27ac141d..317575f0 100644 --- a/src/main/java/com/chargebee/v4/models/taxWithheld/TaxWithheld.java +++ b/src/main/java/com/chargebee/v4/models/taxWithheld/TaxWithheld.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.taxWithheld; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import java.math.BigDecimal; import java.sql.Timestamp; @@ -142,31 +143,35 @@ public static PaymentMethod fromString(String value) { } public static TaxWithheld fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static TaxWithheld fromJson(JsonObject jsonObj) { TaxWithheld obj = new TaxWithheld(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.user = JsonUtil.getString(json, "user"); + obj.user = JsonUtil.getString(jsonObj, "user"); - obj.referenceNumber = JsonUtil.getString(json, "reference_number"); + obj.referenceNumber = JsonUtil.getString(jsonObj, "reference_number"); - obj.description = JsonUtil.getString(json, "description"); + obj.description = JsonUtil.getString(jsonObj, "description"); - obj.type = Type.fromString(JsonUtil.getString(json, "type")); + obj.type = Type.fromString(JsonUtil.getString(jsonObj, "type")); - obj.paymentMethod = PaymentMethod.fromString(JsonUtil.getString(json, "payment_method")); + obj.paymentMethod = PaymentMethod.fromString(JsonUtil.getString(jsonObj, "payment_method")); - obj.date = JsonUtil.getTimestamp(json, "date"); + obj.date = JsonUtil.getTimestamp(jsonObj, "date"); - obj.currencyCode = JsonUtil.getString(json, "currency_code"); + obj.currencyCode = JsonUtil.getString(jsonObj, "currency_code"); - obj.amount = JsonUtil.getLong(json, "amount"); + obj.amount = JsonUtil.getLong(jsonObj, "amount"); - obj.resourceVersion = JsonUtil.getLong(json, "resource_version"); + obj.resourceVersion = JsonUtil.getLong(jsonObj, "resource_version"); - obj.updatedAt = JsonUtil.getTimestamp(json, "updated_at"); + obj.updatedAt = JsonUtil.getTimestamp(jsonObj, "updated_at"); - obj.exchangeRate = JsonUtil.getBigDecimal(json, "exchange_rate"); + obj.exchangeRate = JsonUtil.getBigDecimal(jsonObj, "exchange_rate"); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/thirdPartyConfiguration/ThirdPartyConfiguration.java b/src/main/java/com/chargebee/v4/models/thirdPartyConfiguration/ThirdPartyConfiguration.java index 52bd1c13..7e1719e1 100644 --- a/src/main/java/com/chargebee/v4/models/thirdPartyConfiguration/ThirdPartyConfiguration.java +++ b/src/main/java/com/chargebee/v4/models/thirdPartyConfiguration/ThirdPartyConfiguration.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.thirdPartyConfiguration; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import java.sql.Timestamp; public class ThirdPartyConfiguration { @@ -34,22 +35,26 @@ public java.util.Map getAuthJson() { } public static ThirdPartyConfiguration fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static ThirdPartyConfiguration fromJson(JsonObject jsonObj) { ThirdPartyConfiguration obj = new ThirdPartyConfiguration(); - obj.integrationName = JsonUtil.getString(json, "integration_name"); + obj.integrationName = JsonUtil.getString(jsonObj, "integration_name"); - obj.lastSyncAt = JsonUtil.getTimestamp(json, "last_sync_at"); + obj.lastSyncAt = JsonUtil.getTimestamp(jsonObj, "last_sync_at"); - String __configJsonJson = JsonUtil.getObject(json, "config_json"); + JsonObject __configJsonObj = JsonUtil.getJsonObject(jsonObj, "config_json"); obj.configJson = - __configJsonJson != null - ? JsonUtil.parseJsonObjectToMap(__configJsonJson) + __configJsonObj != null + ? JsonUtil.parseJsonObjectToMap(__configJsonObj) : new java.util.HashMap<>(); - String __authJsonJson = JsonUtil.getObject(json, "auth_json"); + JsonObject __authJsonObj = JsonUtil.getJsonObject(jsonObj, "auth_json"); obj.authJson = - __authJsonJson != null - ? JsonUtil.parseJsonObjectToMap(__authJsonJson) + __authJsonObj != null + ? JsonUtil.parseJsonObjectToMap(__authJsonObj) : new java.util.HashMap<>(); return obj; diff --git a/src/main/java/com/chargebee/v4/models/thirdPartyConfiguration/responses/ThirdPartyConfigurationConfigurationsResponse.java b/src/main/java/com/chargebee/v4/models/thirdPartyConfiguration/responses/ThirdPartyConfigurationConfigurationsResponse.java index 02d9605a..059d5002 100644 --- a/src/main/java/com/chargebee/v4/models/thirdPartyConfiguration/responses/ThirdPartyConfigurationConfigurationsResponse.java +++ b/src/main/java/com/chargebee/v4/models/thirdPartyConfiguration/responses/ThirdPartyConfigurationConfigurationsResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -31,12 +32,14 @@ public static ThirdPartyConfigurationConfigurationsResponse fromJson(String json public static ThirdPartyConfigurationConfigurationsResponse fromJson( String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __thirdPartyConfigurationJson = JsonUtil.getObject(json, "third_party_configuration"); - if (__thirdPartyConfigurationJson != null) { + JsonObject __thirdPartyConfigurationObj = + JsonUtil.getJsonObject(jsonObj, "third_party_configuration"); + if (__thirdPartyConfigurationObj != null) { builder.thirdPartyConfiguration( - ThirdPartyConfiguration.fromJson(__thirdPartyConfigurationJson)); + ThirdPartyConfiguration.fromJson(__thirdPartyConfigurationObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/thirdPartyConfiguration/responses/ThirdPartyConfigurationRetrieveResponse.java b/src/main/java/com/chargebee/v4/models/thirdPartyConfiguration/responses/ThirdPartyConfigurationRetrieveResponse.java index d13ec1df..dda442a8 100644 --- a/src/main/java/com/chargebee/v4/models/thirdPartyConfiguration/responses/ThirdPartyConfigurationRetrieveResponse.java +++ b/src/main/java/com/chargebee/v4/models/thirdPartyConfiguration/responses/ThirdPartyConfigurationRetrieveResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -28,12 +29,14 @@ public static ThirdPartyConfigurationRetrieveResponse fromJson(String json) { public static ThirdPartyConfigurationRetrieveResponse fromJson( String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __thirdPartyConfigurationJson = JsonUtil.getObject(json, "third_party_configuration"); - if (__thirdPartyConfigurationJson != null) { + JsonObject __thirdPartyConfigurationObj = + JsonUtil.getJsonObject(jsonObj, "third_party_configuration"); + if (__thirdPartyConfigurationObj != null) { builder.thirdPartyConfiguration( - ThirdPartyConfiguration.fromJson(__thirdPartyConfigurationJson)); + ThirdPartyConfiguration.fromJson(__thirdPartyConfigurationObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/thirdPartyConfiguration/responses/ThirdPartyConfigurationUpdateResponse.java b/src/main/java/com/chargebee/v4/models/thirdPartyConfiguration/responses/ThirdPartyConfigurationUpdateResponse.java index 10dd4293..3659a234 100644 --- a/src/main/java/com/chargebee/v4/models/thirdPartyConfiguration/responses/ThirdPartyConfigurationUpdateResponse.java +++ b/src/main/java/com/chargebee/v4/models/thirdPartyConfiguration/responses/ThirdPartyConfigurationUpdateResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,12 +28,14 @@ public static ThirdPartyConfigurationUpdateResponse fromJson(String json) { /** Parse JSON response into ThirdPartyConfigurationUpdateResponse object with HTTP response. */ public static ThirdPartyConfigurationUpdateResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __thirdPartyConfigurationJson = JsonUtil.getObject(json, "third_party_configuration"); - if (__thirdPartyConfigurationJson != null) { + JsonObject __thirdPartyConfigurationObj = + JsonUtil.getJsonObject(jsonObj, "third_party_configuration"); + if (__thirdPartyConfigurationObj != null) { builder.thirdPartyConfiguration( - ThirdPartyConfiguration.fromJson(__thirdPartyConfigurationJson)); + ThirdPartyConfiguration.fromJson(__thirdPartyConfigurationObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/thirdPartyEntityMapping/ThirdPartyEntityMapping.java b/src/main/java/com/chargebee/v4/models/thirdPartyEntityMapping/ThirdPartyEntityMapping.java index 008658f9..37c363b4 100644 --- a/src/main/java/com/chargebee/v4/models/thirdPartyEntityMapping/ThirdPartyEntityMapping.java +++ b/src/main/java/com/chargebee/v4/models/thirdPartyEntityMapping/ThirdPartyEntityMapping.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.thirdPartyEntityMapping; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import java.sql.Timestamp; public class ThirdPartyEntityMapping { @@ -259,53 +260,57 @@ public static FailedDependentEntityType fromString(String value) { } public static ThirdPartyEntityMapping fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static ThirdPartyEntityMapping fromJson(JsonObject jsonObj) { ThirdPartyEntityMapping obj = new ThirdPartyEntityMapping(); - obj.entityType = EntityType.fromString(JsonUtil.getString(json, "entity_type")); + obj.entityType = EntityType.fromString(JsonUtil.getString(jsonObj, "entity_type")); - obj.entityExtId = JsonUtil.getString(json, "entity_ext_id"); + obj.entityExtId = JsonUtil.getString(jsonObj, "entity_ext_id"); - obj.integrationName = JsonUtil.getString(json, "integration_name"); + obj.integrationName = JsonUtil.getString(jsonObj, "integration_name"); - obj.thirdPartyEntityId = JsonUtil.getString(json, "third_party_entity_id"); + obj.thirdPartyEntityId = JsonUtil.getString(jsonObj, "third_party_entity_id"); - obj.lastSyncAt = JsonUtil.getTimestamp(json, "last_sync_at"); + obj.lastSyncAt = JsonUtil.getTimestamp(jsonObj, "last_sync_at"); - obj.status = Status.fromString(JsonUtil.getString(json, "status")); + obj.status = Status.fromString(JsonUtil.getString(jsonObj, "status")); obj.failedDependentEntityType = FailedDependentEntityType.fromString( - JsonUtil.getString(json, "failed_dependent_entity_type")); + JsonUtil.getString(jsonObj, "failed_dependent_entity_type")); - obj.errorMessage = JsonUtil.getString(json, "error_message"); + obj.errorMessage = JsonUtil.getString(jsonObj, "error_message"); - obj.url = JsonUtil.getString(json, "url"); + obj.url = JsonUtil.getString(jsonObj, "url"); - obj.createdAt = JsonUtil.getTimestamp(json, "created_at"); + obj.createdAt = JsonUtil.getTimestamp(jsonObj, "created_at"); - obj.modifiedAt = JsonUtil.getTimestamp(json, "modified_at"); + obj.modifiedAt = JsonUtil.getTimestamp(jsonObj, "modified_at"); - obj.entityId = JsonUtil.getString(json, "entity_id"); + obj.entityId = JsonUtil.getString(jsonObj, "entity_id"); - String __newResourceJson = JsonUtil.getObject(json, "new_resource"); + JsonObject __newResourceObj = JsonUtil.getJsonObject(jsonObj, "new_resource"); obj.newResource = - __newResourceJson != null - ? JsonUtil.parseJsonObjectToMap(__newResourceJson) + __newResourceObj != null + ? JsonUtil.parseJsonObjectToMap(__newResourceObj) : new java.util.HashMap<>(); - String __oldResourceJson = JsonUtil.getObject(json, "old_resource"); + JsonObject __oldResourceObj = JsonUtil.getJsonObject(jsonObj, "old_resource"); obj.oldResource = - __oldResourceJson != null - ? JsonUtil.parseJsonObjectToMap(__oldResourceJson) + __oldResourceObj != null + ? JsonUtil.parseJsonObjectToMap(__oldResourceObj) : new java.util.HashMap<>(); - String __mappingMetaJson = JsonUtil.getObject(json, "mapping_meta"); + JsonObject __mappingMetaObj = JsonUtil.getJsonObject(jsonObj, "mapping_meta"); obj.mappingMeta = - __mappingMetaJson != null - ? JsonUtil.parseJsonObjectToMap(__mappingMetaJson) + __mappingMetaObj != null + ? JsonUtil.parseJsonObjectToMap(__mappingMetaObj) : new java.util.HashMap<>(); - obj.failedDependentEntityId = JsonUtil.getString(json, "failed_dependent_entity_id"); + obj.failedDependentEntityId = JsonUtil.getString(jsonObj, "failed_dependent_entity_id"); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/thirdPartyEntityMapping/responses/ThirdPartyEntityMappingListAllResponse.java b/src/main/java/com/chargebee/v4/models/thirdPartyEntityMapping/responses/ThirdPartyEntityMappingListAllResponse.java index 08ab87e8..d13f0314 100644 --- a/src/main/java/com/chargebee/v4/models/thirdPartyEntityMapping/responses/ThirdPartyEntityMappingListAllResponse.java +++ b/src/main/java/com/chargebee/v4/models/thirdPartyEntityMapping/responses/ThirdPartyEntityMappingListAllResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -28,12 +29,14 @@ public static ThirdPartyEntityMappingListAllResponse fromJson(String json) { public static ThirdPartyEntityMappingListAllResponse fromJson( String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __thirdPartyEntityMappingJson = JsonUtil.getObject(json, "third_party_entity_mapping"); - if (__thirdPartyEntityMappingJson != null) { + JsonObject __thirdPartyEntityMappingObj = + JsonUtil.getJsonObject(jsonObj, "third_party_entity_mapping"); + if (__thirdPartyEntityMappingObj != null) { builder.thirdPartyEntityMapping( - ThirdPartyEntityMapping.fromJson(__thirdPartyEntityMappingJson)); + ThirdPartyEntityMapping.fromJson(__thirdPartyEntityMappingObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/thirdPartyEntityMapping/responses/ThirdPartyEntityMappingListResponse.java b/src/main/java/com/chargebee/v4/models/thirdPartyEntityMapping/responses/ThirdPartyEntityMappingListResponse.java index 15dceb51..b81ef89d 100644 --- a/src/main/java/com/chargebee/v4/models/thirdPartyEntityMapping/responses/ThirdPartyEntityMappingListResponse.java +++ b/src/main/java/com/chargebee/v4/models/thirdPartyEntityMapping/responses/ThirdPartyEntityMappingListResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.exceptions.ChargebeeException; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; import com.chargebee.v4.services.ThirdPartyEntityMappingService; import com.chargebee.v4.models.thirdPartyEntityMapping.params.ThirdPartyEntityMappingListParams; @@ -46,13 +47,13 @@ private ThirdPartyEntityMappingListResponse( */ public static ThirdPartyEntityMappingListResponse fromJson(String json) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(ThirdPartyEntityMappingListItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "list"), ThirdPartyEntityMappingListItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new ThirdPartyEntityMappingListResponse(list, nextOffset, null, null, null); } catch (Exception e) { @@ -71,13 +72,13 @@ public static ThirdPartyEntityMappingListResponse fromJson( ThirdPartyEntityMappingListParams originalParams, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(ThirdPartyEntityMappingListItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "list"), ThirdPartyEntityMappingListItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new ThirdPartyEntityMappingListResponse( list, nextOffset, service, originalParams, httpResponse); @@ -186,12 +187,17 @@ public ThirdPartyEntityMapping getThirdPartyEntityMapping() { } public static ThirdPartyEntityMappingListItem fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static ThirdPartyEntityMappingListItem fromJson(JsonObject jsonObj) { ThirdPartyEntityMappingListItem item = new ThirdPartyEntityMappingListItem(); - String __thirdPartyEntityMappingJson = JsonUtil.getObject(json, "third_party_entity_mapping"); - if (__thirdPartyEntityMappingJson != null) { + JsonObject __thirdPartyEntityMappingObj = + JsonUtil.getJsonObject(jsonObj, "third_party_entity_mapping"); + if (__thirdPartyEntityMappingObj != null) { item.thirdPartyEntityMapping = - ThirdPartyEntityMapping.fromJson(__thirdPartyEntityMappingJson); + ThirdPartyEntityMapping.fromJson(__thirdPartyEntityMappingObj); } return item; diff --git a/src/main/java/com/chargebee/v4/models/thirdPartyEntityMapping/responses/ThirdPartyEntityMappingRetrieveEntityResponse.java b/src/main/java/com/chargebee/v4/models/thirdPartyEntityMapping/responses/ThirdPartyEntityMappingRetrieveEntityResponse.java index f340f265..e170e6b9 100644 --- a/src/main/java/com/chargebee/v4/models/thirdPartyEntityMapping/responses/ThirdPartyEntityMappingRetrieveEntityResponse.java +++ b/src/main/java/com/chargebee/v4/models/thirdPartyEntityMapping/responses/ThirdPartyEntityMappingRetrieveEntityResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -31,12 +32,14 @@ public static ThirdPartyEntityMappingRetrieveEntityResponse fromJson(String json public static ThirdPartyEntityMappingRetrieveEntityResponse fromJson( String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __thirdPartyEntityMappingJson = JsonUtil.getObject(json, "third_party_entity_mapping"); - if (__thirdPartyEntityMappingJson != null) { + JsonObject __thirdPartyEntityMappingObj = + JsonUtil.getJsonObject(jsonObj, "third_party_entity_mapping"); + if (__thirdPartyEntityMappingObj != null) { builder.thirdPartyEntityMapping( - ThirdPartyEntityMapping.fromJson(__thirdPartyEntityMappingJson)); + ThirdPartyEntityMapping.fromJson(__thirdPartyEntityMappingObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/thirdPartyEntityMapping/responses/ThirdPartyEntityMappingUpdateEntityResponse.java b/src/main/java/com/chargebee/v4/models/thirdPartyEntityMapping/responses/ThirdPartyEntityMappingUpdateEntityResponse.java index f58d89fb..63ec2986 100644 --- a/src/main/java/com/chargebee/v4/models/thirdPartyEntityMapping/responses/ThirdPartyEntityMappingUpdateEntityResponse.java +++ b/src/main/java/com/chargebee/v4/models/thirdPartyEntityMapping/responses/ThirdPartyEntityMappingUpdateEntityResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -30,12 +31,14 @@ public static ThirdPartyEntityMappingUpdateEntityResponse fromJson(String json) public static ThirdPartyEntityMappingUpdateEntityResponse fromJson( String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __thirdPartyEntityMappingJson = JsonUtil.getObject(json, "third_party_entity_mapping"); - if (__thirdPartyEntityMappingJson != null) { + JsonObject __thirdPartyEntityMappingObj = + JsonUtil.getJsonObject(jsonObj, "third_party_entity_mapping"); + if (__thirdPartyEntityMappingObj != null) { builder.thirdPartyEntityMapping( - ThirdPartyEntityMapping.fromJson(__thirdPartyEntityMappingJson)); + ThirdPartyEntityMapping.fromJson(__thirdPartyEntityMappingObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/thirdPartyPaymentMethod/ThirdPartyPaymentMethod.java b/src/main/java/com/chargebee/v4/models/thirdPartyPaymentMethod/ThirdPartyPaymentMethod.java index a4e9ae8c..9f214a63 100644 --- a/src/main/java/com/chargebee/v4/models/thirdPartyPaymentMethod/ThirdPartyPaymentMethod.java +++ b/src/main/java/com/chargebee/v4/models/thirdPartyPaymentMethod/ThirdPartyPaymentMethod.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.thirdPartyPaymentMethod; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; public class ThirdPartyPaymentMethod { @@ -267,15 +268,19 @@ public static Gateway fromString(String value) { } public static ThirdPartyPaymentMethod fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static ThirdPartyPaymentMethod fromJson(JsonObject jsonObj) { ThirdPartyPaymentMethod obj = new ThirdPartyPaymentMethod(); - obj.type = Type.fromString(JsonUtil.getString(json, "type")); + obj.type = Type.fromString(JsonUtil.getString(jsonObj, "type")); - obj.gateway = Gateway.fromString(JsonUtil.getString(json, "gateway")); + obj.gateway = Gateway.fromString(JsonUtil.getString(jsonObj, "gateway")); - obj.gatewayAccountId = JsonUtil.getString(json, "gateway_account_id"); + obj.gatewayAccountId = JsonUtil.getString(jsonObj, "gateway_account_id"); - obj.referenceId = JsonUtil.getString(json, "reference_id"); + obj.referenceId = JsonUtil.getString(jsonObj, "reference_id"); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/thirdPartySyncDetail/ThirdPartySyncDetail.java b/src/main/java/com/chargebee/v4/models/thirdPartySyncDetail/ThirdPartySyncDetail.java index 44574e38..9198baf0 100644 --- a/src/main/java/com/chargebee/v4/models/thirdPartySyncDetail/ThirdPartySyncDetail.java +++ b/src/main/java/com/chargebee/v4/models/thirdPartySyncDetail/ThirdPartySyncDetail.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.thirdPartySyncDetail; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; public class ThirdPartySyncDetail { @@ -67,18 +68,22 @@ public static Status fromString(String value) { } public static ThirdPartySyncDetail fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static ThirdPartySyncDetail fromJson(JsonObject jsonObj) { ThirdPartySyncDetail obj = new ThirdPartySyncDetail(); - obj.integrationName = JsonUtil.getString(json, "integration_name"); + obj.integrationName = JsonUtil.getString(jsonObj, "integration_name"); - obj.status = Status.fromString(JsonUtil.getString(json, "status")); + obj.status = Status.fromString(JsonUtil.getString(jsonObj, "status")); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - String __contextJson = JsonUtil.getObject(json, "context"); + JsonObject __contextObj = JsonUtil.getJsonObject(jsonObj, "context"); obj.context = - __contextJson != null - ? JsonUtil.parseJsonObjectToMap(__contextJson) + __contextObj != null + ? JsonUtil.parseJsonObjectToMap(__contextObj) : new java.util.HashMap<>(); return obj; diff --git a/src/main/java/com/chargebee/v4/models/thirdPartySyncDetail/responses/ThirdPartySyncDetailCreateResponse.java b/src/main/java/com/chargebee/v4/models/thirdPartySyncDetail/responses/ThirdPartySyncDetailCreateResponse.java index 50785db9..b9101445 100644 --- a/src/main/java/com/chargebee/v4/models/thirdPartySyncDetail/responses/ThirdPartySyncDetailCreateResponse.java +++ b/src/main/java/com/chargebee/v4/models/thirdPartySyncDetail/responses/ThirdPartySyncDetailCreateResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,13 @@ public static ThirdPartySyncDetailCreateResponse fromJson(String json) { /** Parse JSON response into ThirdPartySyncDetailCreateResponse object with HTTP response. */ public static ThirdPartySyncDetailCreateResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __thirdPartySyncDetailJson = JsonUtil.getObject(json, "third_party_sync_detail"); - if (__thirdPartySyncDetailJson != null) { - builder.thirdPartySyncDetail(ThirdPartySyncDetail.fromJson(__thirdPartySyncDetailJson)); + JsonObject __thirdPartySyncDetailObj = + JsonUtil.getJsonObject(jsonObj, "third_party_sync_detail"); + if (__thirdPartySyncDetailObj != null) { + builder.thirdPartySyncDetail(ThirdPartySyncDetail.fromJson(__thirdPartySyncDetailObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/thirdPartySyncDetail/responses/ThirdPartySyncDetailRetrieveLatestSyncResponse.java b/src/main/java/com/chargebee/v4/models/thirdPartySyncDetail/responses/ThirdPartySyncDetailRetrieveLatestSyncResponse.java index f49d63b3..81a22dbc 100644 --- a/src/main/java/com/chargebee/v4/models/thirdPartySyncDetail/responses/ThirdPartySyncDetailRetrieveLatestSyncResponse.java +++ b/src/main/java/com/chargebee/v4/models/thirdPartySyncDetail/responses/ThirdPartySyncDetailRetrieveLatestSyncResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -31,11 +32,13 @@ public static ThirdPartySyncDetailRetrieveLatestSyncResponse fromJson(String jso public static ThirdPartySyncDetailRetrieveLatestSyncResponse fromJson( String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __thirdPartySyncDetailJson = JsonUtil.getObject(json, "third_party_sync_detail"); - if (__thirdPartySyncDetailJson != null) { - builder.thirdPartySyncDetail(ThirdPartySyncDetail.fromJson(__thirdPartySyncDetailJson)); + JsonObject __thirdPartySyncDetailObj = + JsonUtil.getJsonObject(jsonObj, "third_party_sync_detail"); + if (__thirdPartySyncDetailObj != null) { + builder.thirdPartySyncDetail(ThirdPartySyncDetail.fromJson(__thirdPartySyncDetailObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/thirdPartySyncDetail/responses/ThirdPartySyncDetailRetrieveResponse.java b/src/main/java/com/chargebee/v4/models/thirdPartySyncDetail/responses/ThirdPartySyncDetailRetrieveResponse.java index d81bdecf..bbd60351 100644 --- a/src/main/java/com/chargebee/v4/models/thirdPartySyncDetail/responses/ThirdPartySyncDetailRetrieveResponse.java +++ b/src/main/java/com/chargebee/v4/models/thirdPartySyncDetail/responses/ThirdPartySyncDetailRetrieveResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,13 @@ public static ThirdPartySyncDetailRetrieveResponse fromJson(String json) { /** Parse JSON response into ThirdPartySyncDetailRetrieveResponse object with HTTP response. */ public static ThirdPartySyncDetailRetrieveResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __thirdPartySyncDetailJson = JsonUtil.getObject(json, "third_party_sync_detail"); - if (__thirdPartySyncDetailJson != null) { - builder.thirdPartySyncDetail(ThirdPartySyncDetail.fromJson(__thirdPartySyncDetailJson)); + JsonObject __thirdPartySyncDetailObj = + JsonUtil.getJsonObject(jsonObj, "third_party_sync_detail"); + if (__thirdPartySyncDetailObj != null) { + builder.thirdPartySyncDetail(ThirdPartySyncDetail.fromJson(__thirdPartySyncDetailObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/thirdPartySyncDetail/responses/ThirdPartySyncDetailUpdateResponse.java b/src/main/java/com/chargebee/v4/models/thirdPartySyncDetail/responses/ThirdPartySyncDetailUpdateResponse.java index 45adcd08..c9c613bc 100644 --- a/src/main/java/com/chargebee/v4/models/thirdPartySyncDetail/responses/ThirdPartySyncDetailUpdateResponse.java +++ b/src/main/java/com/chargebee/v4/models/thirdPartySyncDetail/responses/ThirdPartySyncDetailUpdateResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,13 @@ public static ThirdPartySyncDetailUpdateResponse fromJson(String json) { /** Parse JSON response into ThirdPartySyncDetailUpdateResponse object with HTTP response. */ public static ThirdPartySyncDetailUpdateResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __thirdPartySyncDetailJson = JsonUtil.getObject(json, "third_party_sync_detail"); - if (__thirdPartySyncDetailJson != null) { - builder.thirdPartySyncDetail(ThirdPartySyncDetail.fromJson(__thirdPartySyncDetailJson)); + JsonObject __thirdPartySyncDetailObj = + JsonUtil.getJsonObject(jsonObj, "third_party_sync_detail"); + if (__thirdPartySyncDetailObj != null) { + builder.thirdPartySyncDetail(ThirdPartySyncDetail.fromJson(__thirdPartySyncDetailObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/timeMachine/TimeMachine.java b/src/main/java/com/chargebee/v4/models/timeMachine/TimeMachine.java index d99018cc..6df76895 100644 --- a/src/main/java/com/chargebee/v4/models/timeMachine/TimeMachine.java +++ b/src/main/java/com/chargebee/v4/models/timeMachine/TimeMachine.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.timeMachine; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import java.sql.Timestamp; public class TimeMachine { @@ -81,22 +82,26 @@ public static TimeTravelStatus fromString(String value) { } public static TimeMachine fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static TimeMachine fromJson(JsonObject jsonObj) { TimeMachine obj = new TimeMachine(); - obj.name = JsonUtil.getString(json, "name"); + obj.name = JsonUtil.getString(jsonObj, "name"); obj.timeTravelStatus = - TimeTravelStatus.fromString(JsonUtil.getString(json, "time_travel_status")); + TimeTravelStatus.fromString(JsonUtil.getString(jsonObj, "time_travel_status")); - obj.genesisTime = JsonUtil.getTimestamp(json, "genesis_time"); + obj.genesisTime = JsonUtil.getTimestamp(jsonObj, "genesis_time"); - obj.destinationTime = JsonUtil.getTimestamp(json, "destination_time"); + obj.destinationTime = JsonUtil.getTimestamp(jsonObj, "destination_time"); - obj.failureCode = JsonUtil.getString(json, "failure_code"); + obj.failureCode = JsonUtil.getString(jsonObj, "failure_code"); - obj.failureReason = JsonUtil.getString(json, "failure_reason"); + obj.failureReason = JsonUtil.getString(jsonObj, "failure_reason"); - obj.errorJson = JsonUtil.getString(json, "error_json"); + obj.errorJson = JsonUtil.getString(jsonObj, "error_json"); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/timeMachine/responses/TimeMachineRetrieveResponse.java b/src/main/java/com/chargebee/v4/models/timeMachine/responses/TimeMachineRetrieveResponse.java index ac6708ee..948137fa 100644 --- a/src/main/java/com/chargebee/v4/models/timeMachine/responses/TimeMachineRetrieveResponse.java +++ b/src/main/java/com/chargebee/v4/models/timeMachine/responses/TimeMachineRetrieveResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static TimeMachineRetrieveResponse fromJson(String json) { /** Parse JSON response into TimeMachineRetrieveResponse object with HTTP response. */ public static TimeMachineRetrieveResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __timeMachineJson = JsonUtil.getObject(json, "time_machine"); - if (__timeMachineJson != null) { - builder.timeMachine(TimeMachine.fromJson(__timeMachineJson)); + JsonObject __timeMachineObj = JsonUtil.getJsonObject(jsonObj, "time_machine"); + if (__timeMachineObj != null) { + builder.timeMachine(TimeMachine.fromJson(__timeMachineObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/timeMachine/responses/TimeMachineStartAfreshResponse.java b/src/main/java/com/chargebee/v4/models/timeMachine/responses/TimeMachineStartAfreshResponse.java index 42826d22..4da12c61 100644 --- a/src/main/java/com/chargebee/v4/models/timeMachine/responses/TimeMachineStartAfreshResponse.java +++ b/src/main/java/com/chargebee/v4/models/timeMachine/responses/TimeMachineStartAfreshResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static TimeMachineStartAfreshResponse fromJson(String json) { /** Parse JSON response into TimeMachineStartAfreshResponse object with HTTP response. */ public static TimeMachineStartAfreshResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __timeMachineJson = JsonUtil.getObject(json, "time_machine"); - if (__timeMachineJson != null) { - builder.timeMachine(TimeMachine.fromJson(__timeMachineJson)); + JsonObject __timeMachineObj = JsonUtil.getJsonObject(jsonObj, "time_machine"); + if (__timeMachineObj != null) { + builder.timeMachine(TimeMachine.fromJson(__timeMachineObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/timeMachine/responses/TimeMachineTravelForwardResponse.java b/src/main/java/com/chargebee/v4/models/timeMachine/responses/TimeMachineTravelForwardResponse.java index 68f1d9fa..78e2c202 100644 --- a/src/main/java/com/chargebee/v4/models/timeMachine/responses/TimeMachineTravelForwardResponse.java +++ b/src/main/java/com/chargebee/v4/models/timeMachine/responses/TimeMachineTravelForwardResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static TimeMachineTravelForwardResponse fromJson(String json) { /** Parse JSON response into TimeMachineTravelForwardResponse object with HTTP response. */ public static TimeMachineTravelForwardResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __timeMachineJson = JsonUtil.getObject(json, "time_machine"); - if (__timeMachineJson != null) { - builder.timeMachine(TimeMachine.fromJson(__timeMachineJson)); + JsonObject __timeMachineObj = JsonUtil.getJsonObject(jsonObj, "time_machine"); + if (__timeMachineObj != null) { + builder.timeMachine(TimeMachine.fromJson(__timeMachineObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/token/Token.java b/src/main/java/com/chargebee/v4/models/token/Token.java index e794e748..a8142774 100644 --- a/src/main/java/com/chargebee/v4/models/token/Token.java +++ b/src/main/java/com/chargebee/v4/models/token/Token.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.token; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import java.sql.Timestamp; public class Token { @@ -366,32 +367,36 @@ public static Vault fromString(String value) { } public static Token fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Token fromJson(JsonObject jsonObj) { Token obj = new Token(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.gateway = Gateway.fromString(JsonUtil.getString(json, "gateway")); + obj.gateway = Gateway.fromString(JsonUtil.getString(jsonObj, "gateway")); - obj.gatewayAccountId = JsonUtil.getString(json, "gateway_account_id"); + obj.gatewayAccountId = JsonUtil.getString(jsonObj, "gateway_account_id"); obj.paymentMethodType = - PaymentMethodType.fromString(JsonUtil.getString(json, "payment_method_type")); + PaymentMethodType.fromString(JsonUtil.getString(jsonObj, "payment_method_type")); - obj.status = Status.fromString(JsonUtil.getString(json, "status")); + obj.status = Status.fromString(JsonUtil.getString(jsonObj, "status")); - obj.idAtVault = JsonUtil.getString(json, "id_at_vault"); + obj.idAtVault = JsonUtil.getString(jsonObj, "id_at_vault"); - obj.vault = Vault.fromString(JsonUtil.getString(json, "vault")); + obj.vault = Vault.fromString(JsonUtil.getString(jsonObj, "vault")); - obj.ipAddress = JsonUtil.getString(json, "ip_address"); + obj.ipAddress = JsonUtil.getString(jsonObj, "ip_address"); - obj.resourceVersion = JsonUtil.getLong(json, "resource_version"); + obj.resourceVersion = JsonUtil.getLong(jsonObj, "resource_version"); - obj.updatedAt = JsonUtil.getTimestamp(json, "updated_at"); + obj.updatedAt = JsonUtil.getTimestamp(jsonObj, "updated_at"); - obj.createdAt = JsonUtil.getTimestamp(json, "created_at"); + obj.createdAt = JsonUtil.getTimestamp(jsonObj, "created_at"); - obj.expiredAt = JsonUtil.getTimestamp(json, "expired_at"); + obj.expiredAt = JsonUtil.getTimestamp(jsonObj, "expired_at"); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/tpSiteUser/TpSiteUser.java b/src/main/java/com/chargebee/v4/models/tpSiteUser/TpSiteUser.java index 2872fd5f..800b4559 100644 --- a/src/main/java/com/chargebee/v4/models/tpSiteUser/TpSiteUser.java +++ b/src/main/java/com/chargebee/v4/models/tpSiteUser/TpSiteUser.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.tpSiteUser; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; public class TpSiteUser { @@ -28,13 +29,17 @@ public String getDomain() { } public static TpSiteUser fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static TpSiteUser fromJson(JsonObject jsonObj) { TpSiteUser obj = new TpSiteUser(); - obj.hostedPageToken = JsonUtil.getString(json, "hosted_page_token"); + obj.hostedPageToken = JsonUtil.getString(jsonObj, "hosted_page_token"); - obj.email = JsonUtil.getString(json, "email"); + obj.email = JsonUtil.getString(jsonObj, "email"); - obj.domain = JsonUtil.getString(json, "domain"); + obj.domain = JsonUtil.getString(jsonObj, "domain"); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/tpSiteUser/responses/GuestsForTpSiteUserResponse.java b/src/main/java/com/chargebee/v4/models/tpSiteUser/responses/GuestsForTpSiteUserResponse.java index 479d6e70..a83bba37 100644 --- a/src/main/java/com/chargebee/v4/models/tpSiteUser/responses/GuestsForTpSiteUserResponse.java +++ b/src/main/java/com/chargebee/v4/models/tpSiteUser/responses/GuestsForTpSiteUserResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.exceptions.ChargebeeException; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; import com.chargebee.v4.services.TpSiteUserService; import com.chargebee.v4.models.tpSiteUser.params.GuestsForTpSiteUserParams; @@ -48,13 +49,13 @@ private GuestsForTpSiteUserResponse( */ public static GuestsForTpSiteUserResponse fromJson(String json) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(TpSiteUserGuestsForTpSiteUserItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "list"), TpSiteUserGuestsForTpSiteUserItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new GuestsForTpSiteUserResponse(list, nextOffset, null, null, null, null); } catch (Exception e) { @@ -73,13 +74,13 @@ public static GuestsForTpSiteUserResponse fromJson( String tpSiteUserDomain, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(TpSiteUserGuestsForTpSiteUserItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "list"), TpSiteUserGuestsForTpSiteUserItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new GuestsForTpSiteUserResponse( list, nextOffset, tpSiteUserDomain, service, originalParams, httpResponse); @@ -180,11 +181,15 @@ public TpSiteUser getTpSiteUser() { } public static TpSiteUserGuestsForTpSiteUserItem fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static TpSiteUserGuestsForTpSiteUserItem fromJson(JsonObject jsonObj) { TpSiteUserGuestsForTpSiteUserItem item = new TpSiteUserGuestsForTpSiteUserItem(); - String __tpSiteUserJson = JsonUtil.getObject(json, "tp_site_user"); - if (__tpSiteUserJson != null) { - item.tpSiteUser = TpSiteUser.fromJson(__tpSiteUserJson); + JsonObject __tpSiteUserObj = JsonUtil.getJsonObject(jsonObj, "tp_site_user"); + if (__tpSiteUserObj != null) { + item.tpSiteUser = TpSiteUser.fromJson(__tpSiteUserObj); } return item; diff --git a/src/main/java/com/chargebee/v4/models/tpSiteUser/responses/TpSiteUserPayNowEnableLiveResponse.java b/src/main/java/com/chargebee/v4/models/tpSiteUser/responses/TpSiteUserPayNowEnableLiveResponse.java index b26a31c8..869b5096 100644 --- a/src/main/java/com/chargebee/v4/models/tpSiteUser/responses/TpSiteUserPayNowEnableLiveResponse.java +++ b/src/main/java/com/chargebee/v4/models/tpSiteUser/responses/TpSiteUserPayNowEnableLiveResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static TpSiteUserPayNowEnableLiveResponse fromJson(String json) { /** Parse JSON response into TpSiteUserPayNowEnableLiveResponse object with HTTP response. */ public static TpSiteUserPayNowEnableLiveResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __tpSiteUserJson = JsonUtil.getObject(json, "tp_site_user"); - if (__tpSiteUserJson != null) { - builder.tpSiteUser(TpSiteUser.fromJson(__tpSiteUserJson)); + JsonObject __tpSiteUserObj = JsonUtil.getJsonObject(jsonObj, "tp_site_user"); + if (__tpSiteUserObj != null) { + builder.tpSiteUser(TpSiteUser.fromJson(__tpSiteUserObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/tpSiteUser/responses/UsersForTpSiteUserResponse.java b/src/main/java/com/chargebee/v4/models/tpSiteUser/responses/UsersForTpSiteUserResponse.java index 025cd43b..a4fc3762 100644 --- a/src/main/java/com/chargebee/v4/models/tpSiteUser/responses/UsersForTpSiteUserResponse.java +++ b/src/main/java/com/chargebee/v4/models/tpSiteUser/responses/UsersForTpSiteUserResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.exceptions.ChargebeeException; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; import com.chargebee.v4.services.TpSiteUserService; import com.chargebee.v4.models.tpSiteUser.params.UsersForTpSiteUserParams; @@ -48,13 +49,13 @@ private UsersForTpSiteUserResponse( */ public static UsersForTpSiteUserResponse fromJson(String json) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(TpSiteUserUsersForTpSiteUserItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "list"), TpSiteUserUsersForTpSiteUserItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new UsersForTpSiteUserResponse(list, nextOffset, null, null, null, null); } catch (Exception e) { @@ -73,13 +74,13 @@ public static UsersForTpSiteUserResponse fromJson( String tpSiteUserDomain, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(TpSiteUserUsersForTpSiteUserItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "list"), TpSiteUserUsersForTpSiteUserItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new UsersForTpSiteUserResponse( list, nextOffset, tpSiteUserDomain, service, originalParams, httpResponse); @@ -180,11 +181,15 @@ public TpSiteUser getTpSiteUser() { } public static TpSiteUserUsersForTpSiteUserItem fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static TpSiteUserUsersForTpSiteUserItem fromJson(JsonObject jsonObj) { TpSiteUserUsersForTpSiteUserItem item = new TpSiteUserUsersForTpSiteUserItem(); - String __tpSiteUserJson = JsonUtil.getObject(json, "tp_site_user"); - if (__tpSiteUserJson != null) { - item.tpSiteUser = TpSiteUser.fromJson(__tpSiteUserJson); + JsonObject __tpSiteUserObj = JsonUtil.getJsonObject(jsonObj, "tp_site_user"); + if (__tpSiteUserObj != null) { + item.tpSiteUser = TpSiteUser.fromJson(__tpSiteUserObj); } return item; diff --git a/src/main/java/com/chargebee/v4/models/transaction/Transaction.java b/src/main/java/com/chargebee/v4/models/transaction/Transaction.java index 166cd6fd..5ada3b0a 100644 --- a/src/main/java/com/chargebee/v4/models/transaction/Transaction.java +++ b/src/main/java/com/chargebee/v4/models/transaction/Transaction.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.transaction; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import java.math.BigDecimal; import java.sql.Timestamp; import java.util.List; @@ -660,114 +661,114 @@ public static AuthorizationReason fromString(String value) { } public static Transaction fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Transaction fromJson(JsonObject jsonObj) { Transaction obj = new Transaction(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.customerId = JsonUtil.getString(json, "customer_id"); + obj.customerId = JsonUtil.getString(jsonObj, "customer_id"); - obj.subscriptionId = JsonUtil.getString(json, "subscription_id"); + obj.subscriptionId = JsonUtil.getString(jsonObj, "subscription_id"); - obj.gatewayAccountId = JsonUtil.getString(json, "gateway_account_id"); + obj.gatewayAccountId = JsonUtil.getString(jsonObj, "gateway_account_id"); - obj.paymentSourceId = JsonUtil.getString(json, "payment_source_id"); + obj.paymentSourceId = JsonUtil.getString(jsonObj, "payment_source_id"); - obj.paymentMethod = PaymentMethod.fromString(JsonUtil.getString(json, "payment_method")); + obj.paymentMethod = PaymentMethod.fromString(JsonUtil.getString(jsonObj, "payment_method")); - obj.referenceNumber = JsonUtil.getString(json, "reference_number"); + obj.referenceNumber = JsonUtil.getString(jsonObj, "reference_number"); - obj.gateway = Gateway.fromString(JsonUtil.getString(json, "gateway")); + obj.gateway = Gateway.fromString(JsonUtil.getString(jsonObj, "gateway")); - obj.type = Type.fromString(JsonUtil.getString(json, "type")); + obj.type = Type.fromString(JsonUtil.getString(jsonObj, "type")); - obj.date = JsonUtil.getTimestamp(json, "date"); + obj.date = JsonUtil.getTimestamp(jsonObj, "date"); - obj.settledAt = JsonUtil.getTimestamp(json, "settled_at"); + obj.settledAt = JsonUtil.getTimestamp(jsonObj, "settled_at"); - obj.exchangeRate = JsonUtil.getBigDecimal(json, "exchange_rate"); + obj.exchangeRate = JsonUtil.getBigDecimal(jsonObj, "exchange_rate"); - obj.currencyCode = JsonUtil.getString(json, "currency_code"); + obj.currencyCode = JsonUtil.getString(jsonObj, "currency_code"); - obj.amount = JsonUtil.getLong(json, "amount"); + obj.amount = JsonUtil.getLong(jsonObj, "amount"); - obj.idAtGateway = JsonUtil.getString(json, "id_at_gateway"); + obj.idAtGateway = JsonUtil.getString(jsonObj, "id_at_gateway"); - obj.status = Status.fromString(JsonUtil.getString(json, "status")); + obj.status = Status.fromString(JsonUtil.getString(jsonObj, "status")); - obj.fraudFlag = FraudFlag.fromString(JsonUtil.getString(json, "fraud_flag")); + obj.fraudFlag = FraudFlag.fromString(JsonUtil.getString(jsonObj, "fraud_flag")); - obj.initiatorType = InitiatorType.fromString(JsonUtil.getString(json, "initiator_type")); + obj.initiatorType = InitiatorType.fromString(JsonUtil.getString(jsonObj, "initiator_type")); - obj.threeDSecure = JsonUtil.getBoolean(json, "three_d_secure"); + obj.threeDSecure = JsonUtil.getBoolean(jsonObj, "three_d_secure"); obj.authorizationReason = - AuthorizationReason.fromString(JsonUtil.getString(json, "authorization_reason")); + AuthorizationReason.fromString(JsonUtil.getString(jsonObj, "authorization_reason")); - obj.errorCode = JsonUtil.getString(json, "error_code"); + obj.errorCode = JsonUtil.getString(jsonObj, "error_code"); - obj.errorText = JsonUtil.getString(json, "error_text"); + obj.errorText = JsonUtil.getString(jsonObj, "error_text"); - obj.voidedAt = JsonUtil.getTimestamp(json, "voided_at"); + obj.voidedAt = JsonUtil.getTimestamp(jsonObj, "voided_at"); - obj.resourceVersion = JsonUtil.getLong(json, "resource_version"); + obj.resourceVersion = JsonUtil.getLong(jsonObj, "resource_version"); - obj.updatedAt = JsonUtil.getTimestamp(json, "updated_at"); + obj.updatedAt = JsonUtil.getTimestamp(jsonObj, "updated_at"); - obj.fraudReason = JsonUtil.getString(json, "fraud_reason"); + obj.fraudReason = JsonUtil.getString(jsonObj, "fraud_reason"); - obj.customPaymentMethodId = JsonUtil.getString(json, "custom_payment_method_id"); + obj.customPaymentMethodId = JsonUtil.getString(jsonObj, "custom_payment_method_id"); - obj.amountUnused = JsonUtil.getLong(json, "amount_unused"); + obj.amountUnused = JsonUtil.getLong(jsonObj, "amount_unused"); - obj.maskedCardNumber = JsonUtil.getString(json, "masked_card_number"); + obj.maskedCardNumber = JsonUtil.getString(jsonObj, "masked_card_number"); - obj.referenceTransactionId = JsonUtil.getString(json, "reference_transaction_id"); + obj.referenceTransactionId = JsonUtil.getString(jsonObj, "reference_transaction_id"); - obj.refundedTxnId = JsonUtil.getString(json, "refunded_txn_id"); + obj.refundedTxnId = JsonUtil.getString(jsonObj, "refunded_txn_id"); - obj.referenceAuthorizationId = JsonUtil.getString(json, "reference_authorization_id"); + obj.referenceAuthorizationId = JsonUtil.getString(jsonObj, "reference_authorization_id"); - obj.amountCapturable = JsonUtil.getLong(json, "amount_capturable"); + obj.amountCapturable = JsonUtil.getLong(jsonObj, "amount_capturable"); - obj.reversalTransactionId = JsonUtil.getString(json, "reversal_transaction_id"); + obj.reversalTransactionId = JsonUtil.getString(jsonObj, "reversal_transaction_id"); - obj.deleted = JsonUtil.getBoolean(json, "deleted"); + obj.deleted = JsonUtil.getBoolean(jsonObj, "deleted"); - obj.iin = JsonUtil.getString(json, "iin"); + obj.iin = JsonUtil.getString(jsonObj, "iin"); - obj.last4 = JsonUtil.getString(json, "last4"); + obj.last4 = JsonUtil.getString(jsonObj, "last4"); - obj.merchantReferenceId = JsonUtil.getString(json, "merchant_reference_id"); + obj.merchantReferenceId = JsonUtil.getString(jsonObj, "merchant_reference_id"); - obj.businessEntityId = JsonUtil.getString(json, "business_entity_id"); + obj.businessEntityId = JsonUtil.getString(jsonObj, "business_entity_id"); - obj.paymentMethodDetails = JsonUtil.getString(json, "payment_method_details"); + obj.paymentMethodDetails = JsonUtil.getString(jsonObj, "payment_method_details"); - obj.customPaymentMethodName = JsonUtil.getString(json, "custom_payment_method_name"); + obj.customPaymentMethodName = JsonUtil.getString(jsonObj, "custom_payment_method_name"); obj.linkedInvoices = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "linked_invoices")).stream() - .map(LinkedInvoices::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "linked_invoices"), LinkedInvoices::fromJson); obj.linkedCreditNotes = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "linked_credit_notes")).stream() - .map(LinkedCreditNotes::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "linked_credit_notes"), LinkedCreditNotes::fromJson); obj.linkedRefunds = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "linked_refunds")).stream() - .map(LinkedRefunds::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "linked_refunds"), LinkedRefunds::fromJson); obj.linkedPayments = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "linked_payments")).stream() - .map(LinkedPayments::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "linked_payments"), LinkedPayments::fromJson); - String __errorDetailJson = JsonUtil.getObject(json, "error_detail"); - if (__errorDetailJson != null) { - obj.errorDetail = ErrorDetail.fromJson(__errorDetailJson); + JsonObject __errorDetailObj = JsonUtil.getJsonObject(jsonObj, "error_detail"); + if (__errorDetailObj != null) { + obj.errorDetail = ErrorDetail.fromJson(__errorDetailObj); } return obj; @@ -1047,19 +1048,23 @@ public static InvoiceStatus fromString(String value) { } public static LinkedInvoices fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static LinkedInvoices fromJson(JsonObject jsonObj) { LinkedInvoices obj = new LinkedInvoices(); - obj.invoiceId = JsonUtil.getString(json, "invoice_id"); + obj.invoiceId = JsonUtil.getString(jsonObj, "invoice_id"); - obj.appliedAmount = JsonUtil.getLong(json, "applied_amount"); + obj.appliedAmount = JsonUtil.getLong(jsonObj, "applied_amount"); - obj.appliedAt = JsonUtil.getTimestamp(json, "applied_at"); + obj.appliedAt = JsonUtil.getTimestamp(jsonObj, "applied_at"); - obj.invoiceDate = JsonUtil.getTimestamp(json, "invoice_date"); + obj.invoiceDate = JsonUtil.getTimestamp(jsonObj, "invoice_date"); - obj.invoiceTotal = JsonUtil.getLong(json, "invoice_total"); + obj.invoiceTotal = JsonUtil.getLong(jsonObj, "invoice_total"); - obj.invoiceStatus = InvoiceStatus.fromString(JsonUtil.getString(json, "invoice_status")); + obj.invoiceStatus = InvoiceStatus.fromString(JsonUtil.getString(jsonObj, "invoice_status")); return obj; } @@ -1233,25 +1238,29 @@ public static CnStatus fromString(String value) { } public static LinkedCreditNotes fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static LinkedCreditNotes fromJson(JsonObject jsonObj) { LinkedCreditNotes obj = new LinkedCreditNotes(); - obj.cnId = JsonUtil.getString(json, "cn_id"); + obj.cnId = JsonUtil.getString(jsonObj, "cn_id"); - obj.appliedAmount = JsonUtil.getLong(json, "applied_amount"); + obj.appliedAmount = JsonUtil.getLong(jsonObj, "applied_amount"); - obj.appliedAt = JsonUtil.getTimestamp(json, "applied_at"); + obj.appliedAt = JsonUtil.getTimestamp(jsonObj, "applied_at"); - obj.cnReasonCode = CnReasonCode.fromString(JsonUtil.getString(json, "cn_reason_code")); + obj.cnReasonCode = CnReasonCode.fromString(JsonUtil.getString(jsonObj, "cn_reason_code")); - obj.cnCreateReasonCode = JsonUtil.getString(json, "cn_create_reason_code"); + obj.cnCreateReasonCode = JsonUtil.getString(jsonObj, "cn_create_reason_code"); - obj.cnDate = JsonUtil.getTimestamp(json, "cn_date"); + obj.cnDate = JsonUtil.getTimestamp(jsonObj, "cn_date"); - obj.cnTotal = JsonUtil.getLong(json, "cn_total"); + obj.cnTotal = JsonUtil.getLong(jsonObj, "cn_total"); - obj.cnStatus = CnStatus.fromString(JsonUtil.getString(json, "cn_status")); + obj.cnStatus = CnStatus.fromString(JsonUtil.getString(jsonObj, "cn_status")); - obj.cnReferenceInvoiceId = JsonUtil.getString(json, "cn_reference_invoice_id"); + obj.cnReferenceInvoiceId = JsonUtil.getString(jsonObj, "cn_reference_invoice_id"); return obj; } @@ -1375,15 +1384,19 @@ public static TxnStatus fromString(String value) { } public static LinkedRefunds fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static LinkedRefunds fromJson(JsonObject jsonObj) { LinkedRefunds obj = new LinkedRefunds(); - obj.txnId = JsonUtil.getString(json, "txn_id"); + obj.txnId = JsonUtil.getString(jsonObj, "txn_id"); - obj.txnStatus = TxnStatus.fromString(JsonUtil.getString(json, "txn_status")); + obj.txnStatus = TxnStatus.fromString(JsonUtil.getString(jsonObj, "txn_status")); - obj.txnDate = JsonUtil.getTimestamp(json, "txn_date"); + obj.txnDate = JsonUtil.getTimestamp(jsonObj, "txn_date"); - obj.txnAmount = JsonUtil.getLong(json, "txn_amount"); + obj.txnAmount = JsonUtil.getLong(jsonObj, "txn_amount"); return obj; } @@ -1483,15 +1496,19 @@ public static Status fromString(String value) { } public static LinkedPayments fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static LinkedPayments fromJson(JsonObject jsonObj) { LinkedPayments obj = new LinkedPayments(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.status = Status.fromString(JsonUtil.getString(json, "status")); + obj.status = Status.fromString(JsonUtil.getString(jsonObj, "status")); - obj.amount = JsonUtil.getLong(json, "amount"); + obj.amount = JsonUtil.getLong(jsonObj, "amount"); - obj.date = JsonUtil.getTimestamp(json, "date"); + obj.date = JsonUtil.getTimestamp(jsonObj, "date"); return obj; } @@ -1608,37 +1625,41 @@ public String getProcessorAdviceCode() { } public static ErrorDetail fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static ErrorDetail fromJson(JsonObject jsonObj) { ErrorDetail obj = new ErrorDetail(); - obj.requestId = JsonUtil.getString(json, "request_id"); + obj.requestId = JsonUtil.getString(jsonObj, "request_id"); - obj.errorCategory = JsonUtil.getString(json, "error_category"); + obj.errorCategory = JsonUtil.getString(jsonObj, "error_category"); - obj.errorCode = JsonUtil.getString(json, "error_code"); + obj.errorCode = JsonUtil.getString(jsonObj, "error_code"); - obj.errorMessage = JsonUtil.getString(json, "error_message"); + obj.errorMessage = JsonUtil.getString(jsonObj, "error_message"); - obj.declineCode = JsonUtil.getString(json, "decline_code"); + obj.declineCode = JsonUtil.getString(jsonObj, "decline_code"); - obj.declineMessage = JsonUtil.getString(json, "decline_message"); + obj.declineMessage = JsonUtil.getString(jsonObj, "decline_message"); - obj.networkErrorCode = JsonUtil.getString(json, "network_error_code"); + obj.networkErrorCode = JsonUtil.getString(jsonObj, "network_error_code"); - obj.networkErrorMessage = JsonUtil.getString(json, "network_error_message"); + obj.networkErrorMessage = JsonUtil.getString(jsonObj, "network_error_message"); - obj.errorField = JsonUtil.getString(json, "error_field"); + obj.errorField = JsonUtil.getString(jsonObj, "error_field"); - obj.recommendationCode = JsonUtil.getString(json, "recommendation_code"); + obj.recommendationCode = JsonUtil.getString(jsonObj, "recommendation_code"); - obj.recommendationMessage = JsonUtil.getString(json, "recommendation_message"); + obj.recommendationMessage = JsonUtil.getString(jsonObj, "recommendation_message"); - obj.processorErrorCode = JsonUtil.getString(json, "processor_error_code"); + obj.processorErrorCode = JsonUtil.getString(jsonObj, "processor_error_code"); - obj.processorErrorMessage = JsonUtil.getString(json, "processor_error_message"); + obj.processorErrorMessage = JsonUtil.getString(jsonObj, "processor_error_message"); - obj.errorCauseId = JsonUtil.getString(json, "error_cause_id"); + obj.errorCauseId = JsonUtil.getString(jsonObj, "error_cause_id"); - obj.processorAdviceCode = JsonUtil.getString(json, "processor_advice_code"); + obj.processorAdviceCode = JsonUtil.getString(jsonObj, "processor_advice_code"); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/transaction/responses/DeleteOfflineTransactionResponse.java b/src/main/java/com/chargebee/v4/models/transaction/responses/DeleteOfflineTransactionResponse.java index ccb3207d..77504b5c 100644 --- a/src/main/java/com/chargebee/v4/models/transaction/responses/DeleteOfflineTransactionResponse.java +++ b/src/main/java/com/chargebee/v4/models/transaction/responses/DeleteOfflineTransactionResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static DeleteOfflineTransactionResponse fromJson(String json) { /** Parse JSON response into DeleteOfflineTransactionResponse object with HTTP response. */ public static DeleteOfflineTransactionResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __transactionJson = JsonUtil.getObject(json, "transaction"); - if (__transactionJson != null) { - builder.transaction(Transaction.fromJson(__transactionJson)); + JsonObject __transactionObj = JsonUtil.getJsonObject(jsonObj, "transaction"); + if (__transactionObj != null) { + builder.transaction(Transaction.fromJson(__transactionObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/transaction/responses/SyncTransactionResponse.java b/src/main/java/com/chargebee/v4/models/transaction/responses/SyncTransactionResponse.java index e5c26a5b..44994455 100644 --- a/src/main/java/com/chargebee/v4/models/transaction/responses/SyncTransactionResponse.java +++ b/src/main/java/com/chargebee/v4/models/transaction/responses/SyncTransactionResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -26,11 +27,12 @@ public static SyncTransactionResponse fromJson(String json) { /** Parse JSON response into SyncTransactionResponse object with HTTP response. */ public static SyncTransactionResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __transactionJson = JsonUtil.getObject(json, "transaction"); - if (__transactionJson != null) { - builder.transaction(Transaction.fromJson(__transactionJson)); + JsonObject __transactionObj = JsonUtil.getJsonObject(jsonObj, "transaction"); + if (__transactionObj != null) { + builder.transaction(Transaction.fromJson(__transactionObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/transaction/responses/TransactionCreateAuthorizationResponse.java b/src/main/java/com/chargebee/v4/models/transaction/responses/TransactionCreateAuthorizationResponse.java index 19a734c2..4eb2df89 100644 --- a/src/main/java/com/chargebee/v4/models/transaction/responses/TransactionCreateAuthorizationResponse.java +++ b/src/main/java/com/chargebee/v4/models/transaction/responses/TransactionCreateAuthorizationResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -28,11 +29,12 @@ public static TransactionCreateAuthorizationResponse fromJson(String json) { public static TransactionCreateAuthorizationResponse fromJson( String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __transactionJson = JsonUtil.getObject(json, "transaction"); - if (__transactionJson != null) { - builder.transaction(Transaction.fromJson(__transactionJson)); + JsonObject __transactionObj = JsonUtil.getJsonObject(jsonObj, "transaction"); + if (__transactionObj != null) { + builder.transaction(Transaction.fromJson(__transactionObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/transaction/responses/TransactionListResponse.java b/src/main/java/com/chargebee/v4/models/transaction/responses/TransactionListResponse.java index fb9ac9ca..a8784b43 100644 --- a/src/main/java/com/chargebee/v4/models/transaction/responses/TransactionListResponse.java +++ b/src/main/java/com/chargebee/v4/models/transaction/responses/TransactionListResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.exceptions.ChargebeeException; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; import com.chargebee.v4.services.TransactionService; import com.chargebee.v4.models.transaction.params.TransactionListParams; @@ -43,13 +44,12 @@ private TransactionListResponse( */ public static TransactionListResponse fromJson(String json) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(TransactionListItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "list"), TransactionListItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new TransactionListResponse(list, nextOffset, null, null, null); } catch (Exception e) { @@ -67,13 +67,12 @@ public static TransactionListResponse fromJson( TransactionListParams originalParams, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(TransactionListItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "list"), TransactionListItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new TransactionListResponse(list, nextOffset, service, originalParams, httpResponse); } catch (Exception e) { @@ -173,11 +172,15 @@ public Transaction getTransaction() { } public static TransactionListItem fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static TransactionListItem fromJson(JsonObject jsonObj) { TransactionListItem item = new TransactionListItem(); - String __transactionJson = JsonUtil.getObject(json, "transaction"); - if (__transactionJson != null) { - item.transaction = Transaction.fromJson(__transactionJson); + JsonObject __transactionObj = JsonUtil.getJsonObject(jsonObj, "transaction"); + if (__transactionObj != null) { + item.transaction = Transaction.fromJson(__transactionObj); } return item; diff --git a/src/main/java/com/chargebee/v4/models/transaction/responses/TransactionPaymentsForInvoiceResponse.java b/src/main/java/com/chargebee/v4/models/transaction/responses/TransactionPaymentsForInvoiceResponse.java index 7e176860..cd26a230 100644 --- a/src/main/java/com/chargebee/v4/models/transaction/responses/TransactionPaymentsForInvoiceResponse.java +++ b/src/main/java/com/chargebee/v4/models/transaction/responses/TransactionPaymentsForInvoiceResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.exceptions.ChargebeeException; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; import com.chargebee.v4.services.TransactionService; import com.chargebee.v4.models.transaction.params.TransactionPaymentsForInvoiceParams; @@ -51,13 +52,13 @@ private TransactionPaymentsForInvoiceResponse( */ public static TransactionPaymentsForInvoiceResponse fromJson(String json) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(TransactionPaymentsForInvoiceItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "list"), TransactionPaymentsForInvoiceItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new TransactionPaymentsForInvoiceResponse(list, nextOffset, null, null, null, null); } catch (Exception e) { @@ -77,13 +78,13 @@ public static TransactionPaymentsForInvoiceResponse fromJson( String invoiceId, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(TransactionPaymentsForInvoiceItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "list"), TransactionPaymentsForInvoiceItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new TransactionPaymentsForInvoiceResponse( list, nextOffset, invoiceId, service, originalParams, httpResponse); @@ -192,11 +193,15 @@ public Transaction getTransaction() { } public static TransactionPaymentsForInvoiceItem fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static TransactionPaymentsForInvoiceItem fromJson(JsonObject jsonObj) { TransactionPaymentsForInvoiceItem item = new TransactionPaymentsForInvoiceItem(); - String __transactionJson = JsonUtil.getObject(json, "transaction"); - if (__transactionJson != null) { - item.transaction = Transaction.fromJson(__transactionJson); + JsonObject __transactionObj = JsonUtil.getJsonObject(jsonObj, "transaction"); + if (__transactionObj != null) { + item.transaction = Transaction.fromJson(__transactionObj); } return item; diff --git a/src/main/java/com/chargebee/v4/models/transaction/responses/TransactionReconcileResponse.java b/src/main/java/com/chargebee/v4/models/transaction/responses/TransactionReconcileResponse.java index 01874cd6..18678dd9 100644 --- a/src/main/java/com/chargebee/v4/models/transaction/responses/TransactionReconcileResponse.java +++ b/src/main/java/com/chargebee/v4/models/transaction/responses/TransactionReconcileResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static TransactionReconcileResponse fromJson(String json) { /** Parse JSON response into TransactionReconcileResponse object with HTTP response. */ public static TransactionReconcileResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __transactionJson = JsonUtil.getObject(json, "transaction"); - if (__transactionJson != null) { - builder.transaction(Transaction.fromJson(__transactionJson)); + JsonObject __transactionObj = JsonUtil.getJsonObject(jsonObj, "transaction"); + if (__transactionObj != null) { + builder.transaction(Transaction.fromJson(__transactionObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/transaction/responses/TransactionRecordRefundResponse.java b/src/main/java/com/chargebee/v4/models/transaction/responses/TransactionRecordRefundResponse.java index 96919fbb..b912e309 100644 --- a/src/main/java/com/chargebee/v4/models/transaction/responses/TransactionRecordRefundResponse.java +++ b/src/main/java/com/chargebee/v4/models/transaction/responses/TransactionRecordRefundResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static TransactionRecordRefundResponse fromJson(String json) { /** Parse JSON response into TransactionRecordRefundResponse object with HTTP response. */ public static TransactionRecordRefundResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __transactionJson = JsonUtil.getObject(json, "transaction"); - if (__transactionJson != null) { - builder.transaction(Transaction.fromJson(__transactionJson)); + JsonObject __transactionObj = JsonUtil.getJsonObject(jsonObj, "transaction"); + if (__transactionObj != null) { + builder.transaction(Transaction.fromJson(__transactionObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/transaction/responses/TransactionRefundResponse.java b/src/main/java/com/chargebee/v4/models/transaction/responses/TransactionRefundResponse.java index 2ba9e634..0fa67baa 100644 --- a/src/main/java/com/chargebee/v4/models/transaction/responses/TransactionRefundResponse.java +++ b/src/main/java/com/chargebee/v4/models/transaction/responses/TransactionRefundResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static TransactionRefundResponse fromJson(String json) { /** Parse JSON response into TransactionRefundResponse object with HTTP response. */ public static TransactionRefundResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __transactionJson = JsonUtil.getObject(json, "transaction"); - if (__transactionJson != null) { - builder.transaction(Transaction.fromJson(__transactionJson)); + JsonObject __transactionObj = JsonUtil.getJsonObject(jsonObj, "transaction"); + if (__transactionObj != null) { + builder.transaction(Transaction.fromJson(__transactionObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/transaction/responses/TransactionRetrieveResponse.java b/src/main/java/com/chargebee/v4/models/transaction/responses/TransactionRetrieveResponse.java index 26558ff4..cc43acf1 100644 --- a/src/main/java/com/chargebee/v4/models/transaction/responses/TransactionRetrieveResponse.java +++ b/src/main/java/com/chargebee/v4/models/transaction/responses/TransactionRetrieveResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static TransactionRetrieveResponse fromJson(String json) { /** Parse JSON response into TransactionRetrieveResponse object with HTTP response. */ public static TransactionRetrieveResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __transactionJson = JsonUtil.getObject(json, "transaction"); - if (__transactionJson != null) { - builder.transaction(Transaction.fromJson(__transactionJson)); + JsonObject __transactionObj = JsonUtil.getJsonObject(jsonObj, "transaction"); + if (__transactionObj != null) { + builder.transaction(Transaction.fromJson(__transactionObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/transaction/responses/TransactionsForCustomerResponse.java b/src/main/java/com/chargebee/v4/models/transaction/responses/TransactionsForCustomerResponse.java index f3fd20ca..c53990e5 100644 --- a/src/main/java/com/chargebee/v4/models/transaction/responses/TransactionsForCustomerResponse.java +++ b/src/main/java/com/chargebee/v4/models/transaction/responses/TransactionsForCustomerResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.exceptions.ChargebeeException; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; import com.chargebee.v4.services.TransactionService; import com.chargebee.v4.models.transaction.params.TransactionsForCustomerParams; @@ -50,13 +51,14 @@ private TransactionsForCustomerResponse( */ public static TransactionsForCustomerResponse fromJson(String json) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(TransactionTransactionsForCustomerItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "list"), + TransactionTransactionsForCustomerItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new TransactionsForCustomerResponse(list, nextOffset, null, null, null, null); } catch (Exception e) { @@ -75,13 +77,14 @@ public static TransactionsForCustomerResponse fromJson( String customerId, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(TransactionTransactionsForCustomerItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "list"), + TransactionTransactionsForCustomerItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new TransactionsForCustomerResponse( list, nextOffset, customerId, service, originalParams, httpResponse); @@ -184,11 +187,15 @@ public Transaction getTransaction() { } public static TransactionTransactionsForCustomerItem fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static TransactionTransactionsForCustomerItem fromJson(JsonObject jsonObj) { TransactionTransactionsForCustomerItem item = new TransactionTransactionsForCustomerItem(); - String __transactionJson = JsonUtil.getObject(json, "transaction"); - if (__transactionJson != null) { - item.transaction = Transaction.fromJson(__transactionJson); + JsonObject __transactionObj = JsonUtil.getJsonObject(jsonObj, "transaction"); + if (__transactionObj != null) { + item.transaction = Transaction.fromJson(__transactionObj); } return item; diff --git a/src/main/java/com/chargebee/v4/models/transaction/responses/TransactionsForSubscriptionResponse.java b/src/main/java/com/chargebee/v4/models/transaction/responses/TransactionsForSubscriptionResponse.java index 0b242e5b..fabe8595 100644 --- a/src/main/java/com/chargebee/v4/models/transaction/responses/TransactionsForSubscriptionResponse.java +++ b/src/main/java/com/chargebee/v4/models/transaction/responses/TransactionsForSubscriptionResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.exceptions.ChargebeeException; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; import com.chargebee.v4.services.TransactionService; import com.chargebee.v4.models.transaction.params.TransactionsForSubscriptionParams; @@ -51,13 +52,14 @@ private TransactionsForSubscriptionResponse( */ public static TransactionsForSubscriptionResponse fromJson(String json) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(TransactionTransactionsForSubscriptionItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "list"), + TransactionTransactionsForSubscriptionItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new TransactionsForSubscriptionResponse(list, nextOffset, null, null, null, null); } catch (Exception e) { @@ -77,13 +79,14 @@ public static TransactionsForSubscriptionResponse fromJson( String subscriptionId, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(TransactionTransactionsForSubscriptionItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "list"), + TransactionTransactionsForSubscriptionItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new TransactionsForSubscriptionResponse( list, nextOffset, subscriptionId, service, originalParams, httpResponse); @@ -192,12 +195,16 @@ public Transaction getTransaction() { } public static TransactionTransactionsForSubscriptionItem fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static TransactionTransactionsForSubscriptionItem fromJson(JsonObject jsonObj) { TransactionTransactionsForSubscriptionItem item = new TransactionTransactionsForSubscriptionItem(); - String __transactionJson = JsonUtil.getObject(json, "transaction"); - if (__transactionJson != null) { - item.transaction = Transaction.fromJson(__transactionJson); + JsonObject __transactionObj = JsonUtil.getJsonObject(jsonObj, "transaction"); + if (__transactionObj != null) { + item.transaction = Transaction.fromJson(__transactionObj); } return item; diff --git a/src/main/java/com/chargebee/v4/models/transaction/responses/VoidTransactionResponse.java b/src/main/java/com/chargebee/v4/models/transaction/responses/VoidTransactionResponse.java index a0c79183..22f93be2 100644 --- a/src/main/java/com/chargebee/v4/models/transaction/responses/VoidTransactionResponse.java +++ b/src/main/java/com/chargebee/v4/models/transaction/responses/VoidTransactionResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -26,11 +27,12 @@ public static VoidTransactionResponse fromJson(String json) { /** Parse JSON response into VoidTransactionResponse object with HTTP response. */ public static VoidTransactionResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __transactionJson = JsonUtil.getObject(json, "transaction"); - if (__transactionJson != null) { - builder.transaction(Transaction.fromJson(__transactionJson)); + JsonObject __transactionObj = JsonUtil.getJsonObject(jsonObj, "transaction"); + if (__transactionObj != null) { + builder.transaction(Transaction.fromJson(__transactionObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/unbilledCharge/UnbilledCharge.java b/src/main/java/com/chargebee/v4/models/unbilledCharge/UnbilledCharge.java index 1c5958f3..005563c8 100644 --- a/src/main/java/com/chargebee/v4/models/unbilledCharge/UnbilledCharge.java +++ b/src/main/java/com/chargebee/v4/models/unbilledCharge/UnbilledCharge.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.unbilledCharge; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import java.sql.Timestamp; import java.util.List; @@ -207,58 +208,59 @@ public static EntityType fromString(String value) { } public static UnbilledCharge fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static UnbilledCharge fromJson(JsonObject jsonObj) { UnbilledCharge obj = new UnbilledCharge(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.customerId = JsonUtil.getString(json, "customer_id"); + obj.customerId = JsonUtil.getString(jsonObj, "customer_id"); - obj.subscriptionId = JsonUtil.getString(json, "subscription_id"); + obj.subscriptionId = JsonUtil.getString(jsonObj, "subscription_id"); - obj.dateFrom = JsonUtil.getTimestamp(json, "date_from"); + obj.dateFrom = JsonUtil.getTimestamp(jsonObj, "date_from"); - obj.dateTo = JsonUtil.getTimestamp(json, "date_to"); + obj.dateTo = JsonUtil.getTimestamp(jsonObj, "date_to"); - obj.unitAmount = JsonUtil.getLong(json, "unit_amount"); + obj.unitAmount = JsonUtil.getLong(jsonObj, "unit_amount"); - obj.pricingModel = PricingModel.fromString(JsonUtil.getString(json, "pricing_model")); + obj.pricingModel = PricingModel.fromString(JsonUtil.getString(jsonObj, "pricing_model")); - obj.quantity = JsonUtil.getInteger(json, "quantity"); + obj.quantity = JsonUtil.getInteger(jsonObj, "quantity"); - obj.amount = JsonUtil.getLong(json, "amount"); + obj.amount = JsonUtil.getLong(jsonObj, "amount"); - obj.currencyCode = JsonUtil.getString(json, "currency_code"); + obj.currencyCode = JsonUtil.getString(jsonObj, "currency_code"); - obj.discountAmount = JsonUtil.getLong(json, "discount_amount"); + obj.discountAmount = JsonUtil.getLong(jsonObj, "discount_amount"); - obj.description = JsonUtil.getString(json, "description"); + obj.description = JsonUtil.getString(jsonObj, "description"); - obj.entityType = EntityType.fromString(JsonUtil.getString(json, "entity_type")); + obj.entityType = EntityType.fromString(JsonUtil.getString(jsonObj, "entity_type")); - obj.entityId = JsonUtil.getString(json, "entity_id"); + obj.entityId = JsonUtil.getString(jsonObj, "entity_id"); - obj.isVoided = JsonUtil.getBoolean(json, "is_voided"); + obj.isVoided = JsonUtil.getBoolean(jsonObj, "is_voided"); - obj.voidedAt = JsonUtil.getTimestamp(json, "voided_at"); + obj.voidedAt = JsonUtil.getTimestamp(jsonObj, "voided_at"); - obj.unitAmountInDecimal = JsonUtil.getString(json, "unit_amount_in_decimal"); + obj.unitAmountInDecimal = JsonUtil.getString(jsonObj, "unit_amount_in_decimal"); - obj.quantityInDecimal = JsonUtil.getString(json, "quantity_in_decimal"); + obj.quantityInDecimal = JsonUtil.getString(jsonObj, "quantity_in_decimal"); - obj.amountInDecimal = JsonUtil.getString(json, "amount_in_decimal"); + obj.amountInDecimal = JsonUtil.getString(jsonObj, "amount_in_decimal"); - obj.updatedAt = JsonUtil.getTimestamp(json, "updated_at"); + obj.updatedAt = JsonUtil.getTimestamp(jsonObj, "updated_at"); - obj.isAdvanceCharge = JsonUtil.getBoolean(json, "is_advance_charge"); + obj.isAdvanceCharge = JsonUtil.getBoolean(jsonObj, "is_advance_charge"); - obj.businessEntityId = JsonUtil.getString(json, "business_entity_id"); + obj.businessEntityId = JsonUtil.getString(jsonObj, "business_entity_id"); - obj.deleted = JsonUtil.getBoolean(json, "deleted"); + obj.deleted = JsonUtil.getBoolean(jsonObj, "deleted"); - obj.tiers = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "tiers")).stream() - .map(Tiers::fromJson) - .collect(java.util.stream.Collectors.toList()); + obj.tiers = JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "tiers"), Tiers::fromJson); return obj; } @@ -463,27 +465,31 @@ public static PricingType fromString(String value) { } public static Tiers fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Tiers fromJson(JsonObject jsonObj) { Tiers obj = new Tiers(); - obj.startingUnit = JsonUtil.getInteger(json, "starting_unit"); + obj.startingUnit = JsonUtil.getInteger(jsonObj, "starting_unit"); - obj.endingUnit = JsonUtil.getInteger(json, "ending_unit"); + obj.endingUnit = JsonUtil.getInteger(jsonObj, "ending_unit"); - obj.quantityUsed = JsonUtil.getInteger(json, "quantity_used"); + obj.quantityUsed = JsonUtil.getInteger(jsonObj, "quantity_used"); - obj.unitAmount = JsonUtil.getLong(json, "unit_amount"); + obj.unitAmount = JsonUtil.getLong(jsonObj, "unit_amount"); - obj.startingUnitInDecimal = JsonUtil.getString(json, "starting_unit_in_decimal"); + obj.startingUnitInDecimal = JsonUtil.getString(jsonObj, "starting_unit_in_decimal"); - obj.endingUnitInDecimal = JsonUtil.getString(json, "ending_unit_in_decimal"); + obj.endingUnitInDecimal = JsonUtil.getString(jsonObj, "ending_unit_in_decimal"); - obj.quantityUsedInDecimal = JsonUtil.getString(json, "quantity_used_in_decimal"); + obj.quantityUsedInDecimal = JsonUtil.getString(jsonObj, "quantity_used_in_decimal"); - obj.unitAmountInDecimal = JsonUtil.getString(json, "unit_amount_in_decimal"); + obj.unitAmountInDecimal = JsonUtil.getString(jsonObj, "unit_amount_in_decimal"); - obj.pricingType = PricingType.fromString(JsonUtil.getString(json, "pricing_type")); + obj.pricingType = PricingType.fromString(JsonUtil.getString(jsonObj, "pricing_type")); - obj.packageSize = JsonUtil.getInteger(json, "package_size"); + obj.packageSize = JsonUtil.getInteger(jsonObj, "package_size"); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/unbilledCharge/responses/CreateUnbilledChargeResponse.java b/src/main/java/com/chargebee/v4/models/unbilledCharge/responses/CreateUnbilledChargeResponse.java index 0c36aa5d..12b2c03e 100644 --- a/src/main/java/com/chargebee/v4/models/unbilledCharge/responses/CreateUnbilledChargeResponse.java +++ b/src/main/java/com/chargebee/v4/models/unbilledCharge/responses/CreateUnbilledChargeResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -29,12 +30,12 @@ public static CreateUnbilledChargeResponse fromJson(String json) { /** Parse JSON response into CreateUnbilledChargeResponse object with HTTP response. */ public static CreateUnbilledChargeResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); builder.unbilledCharges( - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "unbilled_charges")).stream() - .map(UnbilledCharge::fromJson) - .collect(java.util.stream.Collectors.toList())); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "unbilled_charges"), UnbilledCharge::fromJson)); builder.httpResponse(httpResponse); return builder.build(); diff --git a/src/main/java/com/chargebee/v4/models/unbilledCharge/responses/InvoiceUnbilledChargesResponse.java b/src/main/java/com/chargebee/v4/models/unbilledCharge/responses/InvoiceUnbilledChargesResponse.java index 317ebef4..d3092e8f 100644 --- a/src/main/java/com/chargebee/v4/models/unbilledCharge/responses/InvoiceUnbilledChargesResponse.java +++ b/src/main/java/com/chargebee/v4/models/unbilledCharge/responses/InvoiceUnbilledChargesResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -29,12 +30,11 @@ public static InvoiceUnbilledChargesResponse fromJson(String json) { /** Parse JSON response into InvoiceUnbilledChargesResponse object with HTTP response. */ public static InvoiceUnbilledChargesResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); builder.invoices( - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "invoices")).stream() - .map(Invoice::fromJson) - .collect(java.util.stream.Collectors.toList())); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "invoices"), Invoice::fromJson)); builder.httpResponse(httpResponse); return builder.build(); diff --git a/src/main/java/com/chargebee/v4/models/unbilledCharge/responses/UnbilledChargeCreateResponse.java b/src/main/java/com/chargebee/v4/models/unbilledCharge/responses/UnbilledChargeCreateResponse.java index 7de6c0ed..6ffa3090 100644 --- a/src/main/java/com/chargebee/v4/models/unbilledCharge/responses/UnbilledChargeCreateResponse.java +++ b/src/main/java/com/chargebee/v4/models/unbilledCharge/responses/UnbilledChargeCreateResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -29,12 +30,12 @@ public static UnbilledChargeCreateResponse fromJson(String json) { /** Parse JSON response into UnbilledChargeCreateResponse object with HTTP response. */ public static UnbilledChargeCreateResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); builder.unbilledCharges( - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "unbilled_charges")).stream() - .map(UnbilledCharge::fromJson) - .collect(java.util.stream.Collectors.toList())); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "unbilled_charges"), UnbilledCharge::fromJson)); builder.httpResponse(httpResponse); return builder.build(); diff --git a/src/main/java/com/chargebee/v4/models/unbilledCharge/responses/UnbilledChargeDeleteResponse.java b/src/main/java/com/chargebee/v4/models/unbilledCharge/responses/UnbilledChargeDeleteResponse.java index 386a9a5f..4f0d6de5 100644 --- a/src/main/java/com/chargebee/v4/models/unbilledCharge/responses/UnbilledChargeDeleteResponse.java +++ b/src/main/java/com/chargebee/v4/models/unbilledCharge/responses/UnbilledChargeDeleteResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static UnbilledChargeDeleteResponse fromJson(String json) { /** Parse JSON response into UnbilledChargeDeleteResponse object with HTTP response. */ public static UnbilledChargeDeleteResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __unbilledChargeJson = JsonUtil.getObject(json, "unbilled_charge"); - if (__unbilledChargeJson != null) { - builder.unbilledCharge(UnbilledCharge.fromJson(__unbilledChargeJson)); + JsonObject __unbilledChargeObj = JsonUtil.getJsonObject(jsonObj, "unbilled_charge"); + if (__unbilledChargeObj != null) { + builder.unbilledCharge(UnbilledCharge.fromJson(__unbilledChargeObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/unbilledCharge/responses/UnbilledChargeInvoiceNowEstimateResponse.java b/src/main/java/com/chargebee/v4/models/unbilledCharge/responses/UnbilledChargeInvoiceNowEstimateResponse.java index 21396988..9b4750c9 100644 --- a/src/main/java/com/chargebee/v4/models/unbilledCharge/responses/UnbilledChargeInvoiceNowEstimateResponse.java +++ b/src/main/java/com/chargebee/v4/models/unbilledCharge/responses/UnbilledChargeInvoiceNowEstimateResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -30,11 +31,12 @@ public static UnbilledChargeInvoiceNowEstimateResponse fromJson(String json) { public static UnbilledChargeInvoiceNowEstimateResponse fromJson( String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __estimateJson = JsonUtil.getObject(json, "estimate"); - if (__estimateJson != null) { - builder.estimate(Estimate.fromJson(__estimateJson)); + JsonObject __estimateObj = JsonUtil.getJsonObject(jsonObj, "estimate"); + if (__estimateObj != null) { + builder.estimate(Estimate.fromJson(__estimateObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/unbilledCharge/responses/UnbilledChargeListResponse.java b/src/main/java/com/chargebee/v4/models/unbilledCharge/responses/UnbilledChargeListResponse.java index 6d070e13..514bf11a 100644 --- a/src/main/java/com/chargebee/v4/models/unbilledCharge/responses/UnbilledChargeListResponse.java +++ b/src/main/java/com/chargebee/v4/models/unbilledCharge/responses/UnbilledChargeListResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.exceptions.ChargebeeException; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; import com.chargebee.v4.services.UnbilledChargeService; import com.chargebee.v4.models.unbilledCharge.params.UnbilledChargeListParams; @@ -43,13 +44,13 @@ private UnbilledChargeListResponse( */ public static UnbilledChargeListResponse fromJson(String json) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(UnbilledChargeListItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "list"), UnbilledChargeListItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new UnbilledChargeListResponse(list, nextOffset, null, null, null); } catch (Exception e) { @@ -67,13 +68,13 @@ public static UnbilledChargeListResponse fromJson( UnbilledChargeListParams originalParams, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(UnbilledChargeListItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "list"), UnbilledChargeListItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new UnbilledChargeListResponse( list, nextOffset, service, originalParams, httpResponse); @@ -174,11 +175,15 @@ public UnbilledCharge getUnbilledCharge() { } public static UnbilledChargeListItem fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static UnbilledChargeListItem fromJson(JsonObject jsonObj) { UnbilledChargeListItem item = new UnbilledChargeListItem(); - String __unbilledChargeJson = JsonUtil.getObject(json, "unbilled_charge"); - if (__unbilledChargeJson != null) { - item.unbilledCharge = UnbilledCharge.fromJson(__unbilledChargeJson); + JsonObject __unbilledChargeObj = JsonUtil.getJsonObject(jsonObj, "unbilled_charge"); + if (__unbilledChargeObj != null) { + item.unbilledCharge = UnbilledCharge.fromJson(__unbilledChargeObj); } return item; diff --git a/src/main/java/com/chargebee/v4/models/unbilledChargesSetting/responses/UnbilledChargesSettingRetrieveResponse.java b/src/main/java/com/chargebee/v4/models/unbilledChargesSetting/responses/UnbilledChargesSettingRetrieveResponse.java index 18b1d7ef..f3b0f525 100644 --- a/src/main/java/com/chargebee/v4/models/unbilledChargesSetting/responses/UnbilledChargesSettingRetrieveResponse.java +++ b/src/main/java/com/chargebee/v4/models/unbilledChargesSetting/responses/UnbilledChargesSettingRetrieveResponse.java @@ -2,6 +2,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -26,9 +27,10 @@ public static UnbilledChargesSettingRetrieveResponse fromJson(String json) { public static UnbilledChargesSettingRetrieveResponse fromJson( String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - builder.unbilledChargesSetting(JsonUtil.getObject(json, "unbilled_charges_setting")); + builder.unbilledChargesSetting(JsonUtil.getObject(jsonObj, "unbilled_charges_setting")); builder.httpResponse(httpResponse); return builder.build(); diff --git a/src/main/java/com/chargebee/v4/models/usage/Usage.java b/src/main/java/com/chargebee/v4/models/usage/Usage.java index 9107cee9..afc4f368 100644 --- a/src/main/java/com/chargebee/v4/models/usage/Usage.java +++ b/src/main/java/com/chargebee/v4/models/usage/Usage.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.usage; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import java.sql.Timestamp; public class Usage { @@ -104,31 +105,35 @@ public static Source fromString(String value) { } public static Usage fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Usage fromJson(JsonObject jsonObj) { Usage obj = new Usage(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.usageDate = JsonUtil.getTimestamp(json, "usage_date"); + obj.usageDate = JsonUtil.getTimestamp(jsonObj, "usage_date"); - obj.subscriptionId = JsonUtil.getString(json, "subscription_id"); + obj.subscriptionId = JsonUtil.getString(jsonObj, "subscription_id"); - obj.itemPriceId = JsonUtil.getString(json, "item_price_id"); + obj.itemPriceId = JsonUtil.getString(jsonObj, "item_price_id"); - obj.invoiceId = JsonUtil.getString(json, "invoice_id"); + obj.invoiceId = JsonUtil.getString(jsonObj, "invoice_id"); - obj.lineItemId = JsonUtil.getString(json, "line_item_id"); + obj.lineItemId = JsonUtil.getString(jsonObj, "line_item_id"); - obj.quantity = JsonUtil.getString(json, "quantity"); + obj.quantity = JsonUtil.getString(jsonObj, "quantity"); - obj.source = Source.fromString(JsonUtil.getString(json, "source")); + obj.source = Source.fromString(JsonUtil.getString(jsonObj, "source")); - obj.note = JsonUtil.getString(json, "note"); + obj.note = JsonUtil.getString(jsonObj, "note"); - obj.resourceVersion = JsonUtil.getLong(json, "resource_version"); + obj.resourceVersion = JsonUtil.getLong(jsonObj, "resource_version"); - obj.updatedAt = JsonUtil.getTimestamp(json, "updated_at"); + obj.updatedAt = JsonUtil.getTimestamp(jsonObj, "updated_at"); - obj.createdAt = JsonUtil.getTimestamp(json, "created_at"); + obj.createdAt = JsonUtil.getTimestamp(jsonObj, "created_at"); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/usage/responses/UsageCreateResponse.java b/src/main/java/com/chargebee/v4/models/usage/responses/UsageCreateResponse.java index d144c726..b8ad50b3 100644 --- a/src/main/java/com/chargebee/v4/models/usage/responses/UsageCreateResponse.java +++ b/src/main/java/com/chargebee/v4/models/usage/responses/UsageCreateResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** Immutable response object for UsageCreate operation. Contains the response data from the API. */ @@ -24,11 +25,12 @@ public static UsageCreateResponse fromJson(String json) { /** Parse JSON response into UsageCreateResponse object with HTTP response. */ public static UsageCreateResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __usageJson = JsonUtil.getObject(json, "usage"); - if (__usageJson != null) { - builder.usage(Usage.fromJson(__usageJson)); + JsonObject __usageObj = JsonUtil.getJsonObject(jsonObj, "usage"); + if (__usageObj != null) { + builder.usage(Usage.fromJson(__usageObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/usage/responses/UsageDeleteResponse.java b/src/main/java/com/chargebee/v4/models/usage/responses/UsageDeleteResponse.java index fced4719..2deb16c6 100644 --- a/src/main/java/com/chargebee/v4/models/usage/responses/UsageDeleteResponse.java +++ b/src/main/java/com/chargebee/v4/models/usage/responses/UsageDeleteResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** Immutable response object for UsageDelete operation. Contains the response data from the API. */ @@ -24,11 +25,12 @@ public static UsageDeleteResponse fromJson(String json) { /** Parse JSON response into UsageDeleteResponse object with HTTP response. */ public static UsageDeleteResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __usageJson = JsonUtil.getObject(json, "usage"); - if (__usageJson != null) { - builder.usage(Usage.fromJson(__usageJson)); + JsonObject __usageObj = JsonUtil.getJsonObject(jsonObj, "usage"); + if (__usageObj != null) { + builder.usage(Usage.fromJson(__usageObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/usage/responses/UsageListResponse.java b/src/main/java/com/chargebee/v4/models/usage/responses/UsageListResponse.java index 492562a0..432b88b3 100644 --- a/src/main/java/com/chargebee/v4/models/usage/responses/UsageListResponse.java +++ b/src/main/java/com/chargebee/v4/models/usage/responses/UsageListResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.exceptions.ChargebeeException; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; import com.chargebee.v4.services.UsageService; import com.chargebee.v4.models.usage.params.UsageListParams; @@ -43,13 +44,12 @@ private UsageListResponse( */ public static UsageListResponse fromJson(String json) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(UsageListItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "list"), UsageListItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new UsageListResponse(list, nextOffset, null, null, null); } catch (Exception e) { @@ -64,13 +64,12 @@ public static UsageListResponse fromJson(String json) { public static UsageListResponse fromJson( String json, UsageService service, UsageListParams originalParams, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(UsageListItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "list"), UsageListItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new UsageListResponse(list, nextOffset, service, originalParams, httpResponse); } catch (Exception e) { @@ -170,11 +169,15 @@ public Usage getUsage() { } public static UsageListItem fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static UsageListItem fromJson(JsonObject jsonObj) { UsageListItem item = new UsageListItem(); - String __usageJson = JsonUtil.getObject(json, "usage"); - if (__usageJson != null) { - item.usage = Usage.fromJson(__usageJson); + JsonObject __usageObj = JsonUtil.getJsonObject(jsonObj, "usage"); + if (__usageObj != null) { + item.usage = Usage.fromJson(__usageObj); } return item; diff --git a/src/main/java/com/chargebee/v4/models/usage/responses/UsagePdfResponse.java b/src/main/java/com/chargebee/v4/models/usage/responses/UsagePdfResponse.java index ada0fda3..674252a7 100644 --- a/src/main/java/com/chargebee/v4/models/usage/responses/UsagePdfResponse.java +++ b/src/main/java/com/chargebee/v4/models/usage/responses/UsagePdfResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** Immutable response object for UsagePdf operation. Contains the response data from the API. */ @@ -24,11 +25,12 @@ public static UsagePdfResponse fromJson(String json) { /** Parse JSON response into UsagePdfResponse object with HTTP response. */ public static UsagePdfResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __downloadJson = JsonUtil.getObject(json, "download"); - if (__downloadJson != null) { - builder.download(Download.fromJson(__downloadJson)); + JsonObject __downloadObj = JsonUtil.getJsonObject(jsonObj, "download"); + if (__downloadObj != null) { + builder.download(Download.fromJson(__downloadObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/usage/responses/UsageRetrieveResponse.java b/src/main/java/com/chargebee/v4/models/usage/responses/UsageRetrieveResponse.java index 882f2875..560eafbe 100644 --- a/src/main/java/com/chargebee/v4/models/usage/responses/UsageRetrieveResponse.java +++ b/src/main/java/com/chargebee/v4/models/usage/responses/UsageRetrieveResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static UsageRetrieveResponse fromJson(String json) { /** Parse JSON response into UsageRetrieveResponse object with HTTP response. */ public static UsageRetrieveResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __usageJson = JsonUtil.getObject(json, "usage"); - if (__usageJson != null) { - builder.usage(Usage.fromJson(__usageJson)); + JsonObject __usageObj = JsonUtil.getJsonObject(jsonObj, "usage"); + if (__usageObj != null) { + builder.usage(Usage.fromJson(__usageObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/usageEvent/UsageEvent.java b/src/main/java/com/chargebee/v4/models/usageEvent/UsageEvent.java index 6f879a4f..bda5ecf7 100644 --- a/src/main/java/com/chargebee/v4/models/usageEvent/UsageEvent.java +++ b/src/main/java/com/chargebee/v4/models/usageEvent/UsageEvent.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.usageEvent; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; public class UsageEvent { @@ -33,18 +34,22 @@ public java.util.Map getProperties() { } public static UsageEvent fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static UsageEvent fromJson(JsonObject jsonObj) { UsageEvent obj = new UsageEvent(); - obj.subscriptionId = JsonUtil.getString(json, "subscription_id"); + obj.subscriptionId = JsonUtil.getString(jsonObj, "subscription_id"); - obj.deduplicationId = JsonUtil.getString(json, "deduplication_id"); + obj.deduplicationId = JsonUtil.getString(jsonObj, "deduplication_id"); - obj.usageTimestamp = JsonUtil.getLong(json, "usage_timestamp"); + obj.usageTimestamp = JsonUtil.getLong(jsonObj, "usage_timestamp"); - String __propertiesJson = JsonUtil.getObject(json, "properties"); + JsonObject __propertiesObj = JsonUtil.getJsonObject(jsonObj, "properties"); obj.properties = - __propertiesJson != null - ? JsonUtil.parseJsonObjectToMap(__propertiesJson) + __propertiesObj != null + ? JsonUtil.parseJsonObjectToMap(__propertiesObj) : new java.util.HashMap<>(); return obj; diff --git a/src/main/java/com/chargebee/v4/models/usageEvent/responses/UsageEventBatchIngestResponse.java b/src/main/java/com/chargebee/v4/models/usageEvent/responses/UsageEventBatchIngestResponse.java index 454d10a8..4bd8d701 100644 --- a/src/main/java/com/chargebee/v4/models/usageEvent/responses/UsageEventBatchIngestResponse.java +++ b/src/main/java/com/chargebee/v4/models/usageEvent/responses/UsageEventBatchIngestResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -31,17 +32,13 @@ public static UsageEventBatchIngestResponse fromJson(String json) { /** Parse JSON response into UsageEventBatchIngestResponse object with HTTP response. */ public static UsageEventBatchIngestResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - builder.batchId(JsonUtil.getString(json, "batch_id")); + builder.batchId(JsonUtil.getString(jsonObj, "batch_id")); - String __failedEventsJson = JsonUtil.getArray(json, "failed_events);"); - if (__failedEventsJson != null) { - builder.failedEvents( - JsonUtil.parseObjectArray(__failedEventsJson).stream() - .map(JsonUtil::parseJsonObjectToMap) - .collect(java.util.stream.Collectors.toList())); - } + builder.failedEvents( + JsonUtil.mapArrayToObjects(JsonUtil.getJsonArray(jsonObj, "failed_events"))); builder.httpResponse(httpResponse); return builder.build(); diff --git a/src/main/java/com/chargebee/v4/models/usageEvent/responses/UsageEventCreateResponse.java b/src/main/java/com/chargebee/v4/models/usageEvent/responses/UsageEventCreateResponse.java index a41d7a57..32024dd5 100644 --- a/src/main/java/com/chargebee/v4/models/usageEvent/responses/UsageEventCreateResponse.java +++ b/src/main/java/com/chargebee/v4/models/usageEvent/responses/UsageEventCreateResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static UsageEventCreateResponse fromJson(String json) { /** Parse JSON response into UsageEventCreateResponse object with HTTP response. */ public static UsageEventCreateResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __usageEventJson = JsonUtil.getObject(json, "usage_event"); - if (__usageEventJson != null) { - builder.usageEvent(UsageEvent.fromJson(__usageEventJson)); + JsonObject __usageEventObj = JsonUtil.getJsonObject(jsonObj, "usage_event"); + if (__usageEventObj != null) { + builder.usageEvent(UsageEvent.fromJson(__usageEventObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/usageFile/UsageFile.java b/src/main/java/com/chargebee/v4/models/usageFile/UsageFile.java index baa5ed63..7a55231f 100644 --- a/src/main/java/com/chargebee/v4/models/usageFile/UsageFile.java +++ b/src/main/java/com/chargebee/v4/models/usageFile/UsageFile.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.usageFile; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import java.sql.Timestamp; public class UsageFile { @@ -133,43 +134,47 @@ public static Status fromString(String value) { } public static UsageFile fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static UsageFile fromJson(JsonObject jsonObj) { UsageFile obj = new UsageFile(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.name = JsonUtil.getString(json, "name"); + obj.name = JsonUtil.getString(jsonObj, "name"); - obj.mimeType = JsonUtil.getString(json, "mime_type"); + obj.mimeType = JsonUtil.getString(jsonObj, "mime_type"); - obj.errorCode = JsonUtil.getString(json, "error_code"); + obj.errorCode = JsonUtil.getString(jsonObj, "error_code"); - obj.errorReason = JsonUtil.getString(json, "error_reason"); + obj.errorReason = JsonUtil.getString(jsonObj, "error_reason"); - obj.status = Status.fromString(JsonUtil.getString(json, "status")); + obj.status = Status.fromString(JsonUtil.getString(jsonObj, "status")); - obj.totalRecordsCount = JsonUtil.getLong(json, "total_records_count"); + obj.totalRecordsCount = JsonUtil.getLong(jsonObj, "total_records_count"); - obj.processedRecordsCount = JsonUtil.getLong(json, "processed_records_count"); + obj.processedRecordsCount = JsonUtil.getLong(jsonObj, "processed_records_count"); - obj.failedRecordsCount = JsonUtil.getLong(json, "failed_records_count"); + obj.failedRecordsCount = JsonUtil.getLong(jsonObj, "failed_records_count"); - obj.fileSizeInBytes = JsonUtil.getLong(json, "file_size_in_bytes"); + obj.fileSizeInBytes = JsonUtil.getLong(jsonObj, "file_size_in_bytes"); - obj.processingStartedAt = JsonUtil.getTimestamp(json, "processing_started_at"); + obj.processingStartedAt = JsonUtil.getTimestamp(jsonObj, "processing_started_at"); - obj.processingCompletedAt = JsonUtil.getTimestamp(json, "processing_completed_at"); + obj.processingCompletedAt = JsonUtil.getTimestamp(jsonObj, "processing_completed_at"); - obj.uploadedBy = JsonUtil.getString(json, "uploaded_by"); + obj.uploadedBy = JsonUtil.getString(jsonObj, "uploaded_by"); - obj.uploadedAt = JsonUtil.getTimestamp(json, "uploaded_at"); + obj.uploadedAt = JsonUtil.getTimestamp(jsonObj, "uploaded_at"); - obj.errorFilePath = JsonUtil.getString(json, "error_file_path"); + obj.errorFilePath = JsonUtil.getString(jsonObj, "error_file_path"); - obj.errorFileUrl = JsonUtil.getString(json, "error_file_url"); + obj.errorFileUrl = JsonUtil.getString(jsonObj, "error_file_url"); - String __uploadDetailsJson = JsonUtil.getObject(json, "upload_details"); - if (__uploadDetailsJson != null) { - obj.uploadDetails = UploadDetails.fromJson(__uploadDetailsJson); + JsonObject __uploadDetailsObj = JsonUtil.getJsonObject(jsonObj, "upload_details"); + if (__uploadDetailsObj != null) { + obj.uploadDetails = UploadDetails.fromJson(__uploadDetailsObj); } return obj; @@ -277,11 +282,15 @@ public Timestamp getExpiresAt() { } public static UploadDetails fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static UploadDetails fromJson(JsonObject jsonObj) { UploadDetails obj = new UploadDetails(); - obj.url = JsonUtil.getString(json, "url"); + obj.url = JsonUtil.getString(jsonObj, "url"); - obj.expiresAt = JsonUtil.getTimestamp(json, "expires_at"); + obj.expiresAt = JsonUtil.getTimestamp(jsonObj, "expires_at"); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/usageFile/responses/UsageFileProcessingStatusResponse.java b/src/main/java/com/chargebee/v4/models/usageFile/responses/UsageFileProcessingStatusResponse.java index 2d64b691..417c04f7 100644 --- a/src/main/java/com/chargebee/v4/models/usageFile/responses/UsageFileProcessingStatusResponse.java +++ b/src/main/java/com/chargebee/v4/models/usageFile/responses/UsageFileProcessingStatusResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static UsageFileProcessingStatusResponse fromJson(String json) { /** Parse JSON response into UsageFileProcessingStatusResponse object with HTTP response. */ public static UsageFileProcessingStatusResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __usageFileJson = JsonUtil.getObject(json, "usage_file"); - if (__usageFileJson != null) { - builder.usageFile(UsageFile.fromJson(__usageFileJson)); + JsonObject __usageFileObj = JsonUtil.getJsonObject(jsonObj, "usage_file"); + if (__usageFileObj != null) { + builder.usageFile(UsageFile.fromJson(__usageFileObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/usageFile/responses/UsageFileUploadUrlResponse.java b/src/main/java/com/chargebee/v4/models/usageFile/responses/UsageFileUploadUrlResponse.java index 42e0b295..a0ffa345 100644 --- a/src/main/java/com/chargebee/v4/models/usageFile/responses/UsageFileUploadUrlResponse.java +++ b/src/main/java/com/chargebee/v4/models/usageFile/responses/UsageFileUploadUrlResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static UsageFileUploadUrlResponse fromJson(String json) { /** Parse JSON response into UsageFileUploadUrlResponse object with HTTP response. */ public static UsageFileUploadUrlResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __usageFileJson = JsonUtil.getObject(json, "usage_file"); - if (__usageFileJson != null) { - builder.usageFile(UsageFile.fromJson(__usageFileJson)); + JsonObject __usageFileObj = JsonUtil.getJsonObject(jsonObj, "usage_file"); + if (__usageFileObj != null) { + builder.usageFile(UsageFile.fromJson(__usageFileObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/usageReminderInfo/UsageReminderInfo.java b/src/main/java/com/chargebee/v4/models/usageReminderInfo/UsageReminderInfo.java index f26feb02..743df7c9 100644 --- a/src/main/java/com/chargebee/v4/models/usageReminderInfo/UsageReminderInfo.java +++ b/src/main/java/com/chargebee/v4/models/usageReminderInfo/UsageReminderInfo.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.usageReminderInfo; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import java.sql.Timestamp; public class UsageReminderInfo { @@ -24,11 +25,15 @@ public Timestamp getUsageDateEnd() { } public static UsageReminderInfo fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static UsageReminderInfo fromJson(JsonObject jsonObj) { UsageReminderInfo obj = new UsageReminderInfo(); - obj.usageDateStart = JsonUtil.getTimestamp(json, "usage_date_start"); + obj.usageDateStart = JsonUtil.getTimestamp(jsonObj, "usage_date_start"); - obj.usageDateEnd = JsonUtil.getTimestamp(json, "usage_date_end"); + obj.usageDateEnd = JsonUtil.getTimestamp(jsonObj, "usage_date_end"); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/variant/Variant.java b/src/main/java/com/chargebee/v4/models/variant/Variant.java index 1c72b89d..b91db7e7 100644 --- a/src/main/java/com/chargebee/v4/models/variant/Variant.java +++ b/src/main/java/com/chargebee/v4/models/variant/Variant.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.variant; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import java.sql.Timestamp; import java.util.List; @@ -108,40 +109,42 @@ public static Status fromString(String value) { } public static Variant fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static Variant fromJson(JsonObject jsonObj) { Variant obj = new Variant(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.name = JsonUtil.getString(json, "name"); + obj.name = JsonUtil.getString(jsonObj, "name"); - obj.externalName = JsonUtil.getString(json, "external_name"); + obj.externalName = JsonUtil.getString(jsonObj, "external_name"); - obj.description = JsonUtil.getString(json, "description"); + obj.description = JsonUtil.getString(jsonObj, "description"); - obj.sku = JsonUtil.getString(json, "sku"); + obj.sku = JsonUtil.getString(jsonObj, "sku"); - obj.deleted = JsonUtil.getBoolean(json, "deleted"); + obj.deleted = JsonUtil.getBoolean(jsonObj, "deleted"); - obj.productId = JsonUtil.getString(json, "product_id"); + obj.productId = JsonUtil.getString(jsonObj, "product_id"); - obj.status = Status.fromString(JsonUtil.getString(json, "status")); + obj.status = Status.fromString(JsonUtil.getString(jsonObj, "status")); - obj.createdAt = JsonUtil.getTimestamp(json, "created_at"); + obj.createdAt = JsonUtil.getTimestamp(jsonObj, "created_at"); - obj.resourceVersion = JsonUtil.getLong(json, "resource_version"); + obj.resourceVersion = JsonUtil.getLong(jsonObj, "resource_version"); - obj.updatedAt = JsonUtil.getTimestamp(json, "updated_at"); + obj.updatedAt = JsonUtil.getTimestamp(jsonObj, "updated_at"); - String __metadataJson = JsonUtil.getObject(json, "metadata"); + JsonObject __metadataObj = JsonUtil.getJsonObject(jsonObj, "metadata"); obj.metadata = - __metadataJson != null - ? JsonUtil.parseJsonObjectToMap(__metadataJson) + __metadataObj != null + ? JsonUtil.parseJsonObjectToMap(__metadataObj) : new java.util.HashMap<>(); obj.optionValues = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "option_values")).stream() - .map(OptionValues::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray(JsonUtil.getJsonArray(jsonObj, "option_values"), OptionValues::fromJson); return obj; } @@ -232,11 +235,15 @@ public String getValue() { } public static OptionValues fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static OptionValues fromJson(JsonObject jsonObj) { OptionValues obj = new OptionValues(); - obj.name = JsonUtil.getString(json, "name"); + obj.name = JsonUtil.getString(jsonObj, "name"); - obj.value = JsonUtil.getString(json, "value"); + obj.value = JsonUtil.getString(jsonObj, "value"); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/variant/responses/CreateProductVariantResponse.java b/src/main/java/com/chargebee/v4/models/variant/responses/CreateProductVariantResponse.java index 3962ca72..daabdb30 100644 --- a/src/main/java/com/chargebee/v4/models/variant/responses/CreateProductVariantResponse.java +++ b/src/main/java/com/chargebee/v4/models/variant/responses/CreateProductVariantResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static CreateProductVariantResponse fromJson(String json) { /** Parse JSON response into CreateProductVariantResponse object with HTTP response. */ public static CreateProductVariantResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __variantJson = JsonUtil.getObject(json, "variant"); - if (__variantJson != null) { - builder.variant(Variant.fromJson(__variantJson)); + JsonObject __variantObj = JsonUtil.getJsonObject(jsonObj, "variant"); + if (__variantObj != null) { + builder.variant(Variant.fromJson(__variantObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/variant/responses/ListProductVariantsResponse.java b/src/main/java/com/chargebee/v4/models/variant/responses/ListProductVariantsResponse.java index 72b9c1ca..3262a49b 100644 --- a/src/main/java/com/chargebee/v4/models/variant/responses/ListProductVariantsResponse.java +++ b/src/main/java/com/chargebee/v4/models/variant/responses/ListProductVariantsResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.exceptions.ChargebeeException; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; import com.chargebee.v4.services.VariantService; import com.chargebee.v4.models.variant.params.ListProductVariantsParams; @@ -48,13 +49,13 @@ private ListProductVariantsResponse( */ public static ListProductVariantsResponse fromJson(String json) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(VariantListProductVariantsItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "list"), VariantListProductVariantsItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new ListProductVariantsResponse(list, nextOffset, null, null, null, null); } catch (Exception e) { @@ -73,13 +74,13 @@ public static ListProductVariantsResponse fromJson( String productId, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(VariantListProductVariantsItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "list"), VariantListProductVariantsItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new ListProductVariantsResponse( list, nextOffset, productId, service, originalParams, httpResponse); @@ -180,11 +181,15 @@ public Variant getVariant() { } public static VariantListProductVariantsItem fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static VariantListProductVariantsItem fromJson(JsonObject jsonObj) { VariantListProductVariantsItem item = new VariantListProductVariantsItem(); - String __variantJson = JsonUtil.getObject(json, "variant"); - if (__variantJson != null) { - item.variant = Variant.fromJson(__variantJson); + JsonObject __variantObj = JsonUtil.getJsonObject(jsonObj, "variant"); + if (__variantObj != null) { + item.variant = Variant.fromJson(__variantObj); } return item; diff --git a/src/main/java/com/chargebee/v4/models/variant/responses/VariantDeleteResponse.java b/src/main/java/com/chargebee/v4/models/variant/responses/VariantDeleteResponse.java index 9dba63d2..53f7a339 100644 --- a/src/main/java/com/chargebee/v4/models/variant/responses/VariantDeleteResponse.java +++ b/src/main/java/com/chargebee/v4/models/variant/responses/VariantDeleteResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -26,11 +27,12 @@ public static VariantDeleteResponse fromJson(String json) { /** Parse JSON response into VariantDeleteResponse object with HTTP response. */ public static VariantDeleteResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __variantJson = JsonUtil.getObject(json, "variant"); - if (__variantJson != null) { - builder.variant(Variant.fromJson(__variantJson)); + JsonObject __variantObj = JsonUtil.getJsonObject(jsonObj, "variant"); + if (__variantObj != null) { + builder.variant(Variant.fromJson(__variantObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/variant/responses/VariantRetrieveResponse.java b/src/main/java/com/chargebee/v4/models/variant/responses/VariantRetrieveResponse.java index a9b4ce3b..a5bd1c31 100644 --- a/src/main/java/com/chargebee/v4/models/variant/responses/VariantRetrieveResponse.java +++ b/src/main/java/com/chargebee/v4/models/variant/responses/VariantRetrieveResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static VariantRetrieveResponse fromJson(String json) { /** Parse JSON response into VariantRetrieveResponse object with HTTP response. */ public static VariantRetrieveResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __variantJson = JsonUtil.getObject(json, "variant"); - if (__variantJson != null) { - builder.variant(Variant.fromJson(__variantJson)); + JsonObject __variantObj = JsonUtil.getJsonObject(jsonObj, "variant"); + if (__variantObj != null) { + builder.variant(Variant.fromJson(__variantObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/variant/responses/VariantUpdateResponse.java b/src/main/java/com/chargebee/v4/models/variant/responses/VariantUpdateResponse.java index b5dff251..fe4c2e29 100644 --- a/src/main/java/com/chargebee/v4/models/variant/responses/VariantUpdateResponse.java +++ b/src/main/java/com/chargebee/v4/models/variant/responses/VariantUpdateResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -26,11 +27,12 @@ public static VariantUpdateResponse fromJson(String json) { /** Parse JSON response into VariantUpdateResponse object with HTTP response. */ public static VariantUpdateResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __variantJson = JsonUtil.getObject(json, "variant"); - if (__variantJson != null) { - builder.variant(Variant.fromJson(__variantJson)); + JsonObject __variantObj = JsonUtil.getJsonObject(jsonObj, "variant"); + if (__variantObj != null) { + builder.variant(Variant.fromJson(__variantObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/virtualBankAccount/VirtualBankAccount.java b/src/main/java/com/chargebee/v4/models/virtualBankAccount/VirtualBankAccount.java index e9e8adcf..b0bb3c1e 100644 --- a/src/main/java/com/chargebee/v4/models/virtualBankAccount/VirtualBankAccount.java +++ b/src/main/java/com/chargebee/v4/models/virtualBankAccount/VirtualBankAccount.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.virtualBankAccount; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import java.sql.Timestamp; public class VirtualBankAccount { @@ -269,37 +270,41 @@ public static Gateway fromString(String value) { } public static VirtualBankAccount fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static VirtualBankAccount fromJson(JsonObject jsonObj) { VirtualBankAccount obj = new VirtualBankAccount(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.customerId = JsonUtil.getString(json, "customer_id"); + obj.customerId = JsonUtil.getString(jsonObj, "customer_id"); - obj.email = JsonUtil.getString(json, "email"); + obj.email = JsonUtil.getString(jsonObj, "email"); - obj.scheme = Scheme.fromString(JsonUtil.getString(json, "scheme")); + obj.scheme = Scheme.fromString(JsonUtil.getString(jsonObj, "scheme")); - obj.bankName = JsonUtil.getString(json, "bank_name"); + obj.bankName = JsonUtil.getString(jsonObj, "bank_name"); - obj.accountNumber = JsonUtil.getString(json, "account_number"); + obj.accountNumber = JsonUtil.getString(jsonObj, "account_number"); - obj.routingNumber = JsonUtil.getString(json, "routing_number"); + obj.routingNumber = JsonUtil.getString(jsonObj, "routing_number"); - obj.swiftCode = JsonUtil.getString(json, "swift_code"); + obj.swiftCode = JsonUtil.getString(jsonObj, "swift_code"); - obj.gateway = Gateway.fromString(JsonUtil.getString(json, "gateway")); + obj.gateway = Gateway.fromString(JsonUtil.getString(jsonObj, "gateway")); - obj.gatewayAccountId = JsonUtil.getString(json, "gateway_account_id"); + obj.gatewayAccountId = JsonUtil.getString(jsonObj, "gateway_account_id"); - obj.resourceVersion = JsonUtil.getLong(json, "resource_version"); + obj.resourceVersion = JsonUtil.getLong(jsonObj, "resource_version"); - obj.updatedAt = JsonUtil.getTimestamp(json, "updated_at"); + obj.updatedAt = JsonUtil.getTimestamp(jsonObj, "updated_at"); - obj.createdAt = JsonUtil.getTimestamp(json, "created_at"); + obj.createdAt = JsonUtil.getTimestamp(jsonObj, "created_at"); - obj.referenceId = JsonUtil.getString(json, "reference_id"); + obj.referenceId = JsonUtil.getString(jsonObj, "reference_id"); - obj.deleted = JsonUtil.getBoolean(json, "deleted"); + obj.deleted = JsonUtil.getBoolean(jsonObj, "deleted"); return obj; } diff --git a/src/main/java/com/chargebee/v4/models/virtualBankAccount/responses/VirtualBankAccountCreateResponse.java b/src/main/java/com/chargebee/v4/models/virtualBankAccount/responses/VirtualBankAccountCreateResponse.java index 0bd26ffa..c3f7e1c6 100644 --- a/src/main/java/com/chargebee/v4/models/virtualBankAccount/responses/VirtualBankAccountCreateResponse.java +++ b/src/main/java/com/chargebee/v4/models/virtualBankAccount/responses/VirtualBankAccountCreateResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -33,16 +34,17 @@ public static VirtualBankAccountCreateResponse fromJson(String json) { /** Parse JSON response into VirtualBankAccountCreateResponse object with HTTP response. */ public static VirtualBankAccountCreateResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __virtualBankAccountJson = JsonUtil.getObject(json, "virtual_bank_account"); - if (__virtualBankAccountJson != null) { - builder.virtualBankAccount(VirtualBankAccount.fromJson(__virtualBankAccountJson)); + JsonObject __virtualBankAccountObj = JsonUtil.getJsonObject(jsonObj, "virtual_bank_account"); + if (__virtualBankAccountObj != null) { + builder.virtualBankAccount(VirtualBankAccount.fromJson(__virtualBankAccountObj)); } - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - builder.customer(Customer.fromJson(__customerJson)); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + builder.customer(Customer.fromJson(__customerObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/virtualBankAccount/responses/VirtualBankAccountCreateUsingPermanentTokenResponse.java b/src/main/java/com/chargebee/v4/models/virtualBankAccount/responses/VirtualBankAccountCreateUsingPermanentTokenResponse.java index 112c581a..e5adda12 100644 --- a/src/main/java/com/chargebee/v4/models/virtualBankAccount/responses/VirtualBankAccountCreateUsingPermanentTokenResponse.java +++ b/src/main/java/com/chargebee/v4/models/virtualBankAccount/responses/VirtualBankAccountCreateUsingPermanentTokenResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -37,16 +38,17 @@ public static VirtualBankAccountCreateUsingPermanentTokenResponse fromJson(Strin public static VirtualBankAccountCreateUsingPermanentTokenResponse fromJson( String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __virtualBankAccountJson = JsonUtil.getObject(json, "virtual_bank_account"); - if (__virtualBankAccountJson != null) { - builder.virtualBankAccount(VirtualBankAccount.fromJson(__virtualBankAccountJson)); + JsonObject __virtualBankAccountObj = JsonUtil.getJsonObject(jsonObj, "virtual_bank_account"); + if (__virtualBankAccountObj != null) { + builder.virtualBankAccount(VirtualBankAccount.fromJson(__virtualBankAccountObj)); } - String __customerJson = JsonUtil.getObject(json, "customer"); - if (__customerJson != null) { - builder.customer(Customer.fromJson(__customerJson)); + JsonObject __customerObj = JsonUtil.getJsonObject(jsonObj, "customer"); + if (__customerObj != null) { + builder.customer(Customer.fromJson(__customerObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/virtualBankAccount/responses/VirtualBankAccountDeleteLocalResponse.java b/src/main/java/com/chargebee/v4/models/virtualBankAccount/responses/VirtualBankAccountDeleteLocalResponse.java index bca0fb77..aac5c10c 100644 --- a/src/main/java/com/chargebee/v4/models/virtualBankAccount/responses/VirtualBankAccountDeleteLocalResponse.java +++ b/src/main/java/com/chargebee/v4/models/virtualBankAccount/responses/VirtualBankAccountDeleteLocalResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static VirtualBankAccountDeleteLocalResponse fromJson(String json) { /** Parse JSON response into VirtualBankAccountDeleteLocalResponse object with HTTP response. */ public static VirtualBankAccountDeleteLocalResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __virtualBankAccountJson = JsonUtil.getObject(json, "virtual_bank_account"); - if (__virtualBankAccountJson != null) { - builder.virtualBankAccount(VirtualBankAccount.fromJson(__virtualBankAccountJson)); + JsonObject __virtualBankAccountObj = JsonUtil.getJsonObject(jsonObj, "virtual_bank_account"); + if (__virtualBankAccountObj != null) { + builder.virtualBankAccount(VirtualBankAccount.fromJson(__virtualBankAccountObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/virtualBankAccount/responses/VirtualBankAccountDeleteResponse.java b/src/main/java/com/chargebee/v4/models/virtualBankAccount/responses/VirtualBankAccountDeleteResponse.java index 8633f8ad..292960f0 100644 --- a/src/main/java/com/chargebee/v4/models/virtualBankAccount/responses/VirtualBankAccountDeleteResponse.java +++ b/src/main/java/com/chargebee/v4/models/virtualBankAccount/responses/VirtualBankAccountDeleteResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static VirtualBankAccountDeleteResponse fromJson(String json) { /** Parse JSON response into VirtualBankAccountDeleteResponse object with HTTP response. */ public static VirtualBankAccountDeleteResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __virtualBankAccountJson = JsonUtil.getObject(json, "virtual_bank_account"); - if (__virtualBankAccountJson != null) { - builder.virtualBankAccount(VirtualBankAccount.fromJson(__virtualBankAccountJson)); + JsonObject __virtualBankAccountObj = JsonUtil.getJsonObject(jsonObj, "virtual_bank_account"); + if (__virtualBankAccountObj != null) { + builder.virtualBankAccount(VirtualBankAccount.fromJson(__virtualBankAccountObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/virtualBankAccount/responses/VirtualBankAccountListResponse.java b/src/main/java/com/chargebee/v4/models/virtualBankAccount/responses/VirtualBankAccountListResponse.java index 1589d59b..051a57fc 100644 --- a/src/main/java/com/chargebee/v4/models/virtualBankAccount/responses/VirtualBankAccountListResponse.java +++ b/src/main/java/com/chargebee/v4/models/virtualBankAccount/responses/VirtualBankAccountListResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.exceptions.ChargebeeException; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; import com.chargebee.v4.services.VirtualBankAccountService; import com.chargebee.v4.models.virtualBankAccount.params.VirtualBankAccountListParams; @@ -43,13 +44,13 @@ private VirtualBankAccountListResponse( */ public static VirtualBankAccountListResponse fromJson(String json) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(VirtualBankAccountListItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "list"), VirtualBankAccountListItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new VirtualBankAccountListResponse(list, nextOffset, null, null, null); } catch (Exception e) { @@ -67,13 +68,13 @@ public static VirtualBankAccountListResponse fromJson( VirtualBankAccountListParams originalParams, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(VirtualBankAccountListItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "list"), VirtualBankAccountListItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new VirtualBankAccountListResponse( list, nextOffset, service, originalParams, httpResponse); @@ -176,11 +177,15 @@ public VirtualBankAccount getVirtualBankAccount() { } public static VirtualBankAccountListItem fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static VirtualBankAccountListItem fromJson(JsonObject jsonObj) { VirtualBankAccountListItem item = new VirtualBankAccountListItem(); - String __virtualBankAccountJson = JsonUtil.getObject(json, "virtual_bank_account"); - if (__virtualBankAccountJson != null) { - item.virtualBankAccount = VirtualBankAccount.fromJson(__virtualBankAccountJson); + JsonObject __virtualBankAccountObj = JsonUtil.getJsonObject(jsonObj, "virtual_bank_account"); + if (__virtualBankAccountObj != null) { + item.virtualBankAccount = VirtualBankAccount.fromJson(__virtualBankAccountObj); } return item; diff --git a/src/main/java/com/chargebee/v4/models/virtualBankAccount/responses/VirtualBankAccountRetrieveResponse.java b/src/main/java/com/chargebee/v4/models/virtualBankAccount/responses/VirtualBankAccountRetrieveResponse.java index 27fbcfcb..63b12e51 100644 --- a/src/main/java/com/chargebee/v4/models/virtualBankAccount/responses/VirtualBankAccountRetrieveResponse.java +++ b/src/main/java/com/chargebee/v4/models/virtualBankAccount/responses/VirtualBankAccountRetrieveResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static VirtualBankAccountRetrieveResponse fromJson(String json) { /** Parse JSON response into VirtualBankAccountRetrieveResponse object with HTTP response. */ public static VirtualBankAccountRetrieveResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __virtualBankAccountJson = JsonUtil.getObject(json, "virtual_bank_account"); - if (__virtualBankAccountJson != null) { - builder.virtualBankAccount(VirtualBankAccount.fromJson(__virtualBankAccountJson)); + JsonObject __virtualBankAccountObj = JsonUtil.getJsonObject(jsonObj, "virtual_bank_account"); + if (__virtualBankAccountObj != null) { + builder.virtualBankAccount(VirtualBankAccount.fromJson(__virtualBankAccountObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/virtualBankAccount/responses/VirtualBankAccountSyncFundResponse.java b/src/main/java/com/chargebee/v4/models/virtualBankAccount/responses/VirtualBankAccountSyncFundResponse.java index 3e98c98a..7e5da197 100644 --- a/src/main/java/com/chargebee/v4/models/virtualBankAccount/responses/VirtualBankAccountSyncFundResponse.java +++ b/src/main/java/com/chargebee/v4/models/virtualBankAccount/responses/VirtualBankAccountSyncFundResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static VirtualBankAccountSyncFundResponse fromJson(String json) { /** Parse JSON response into VirtualBankAccountSyncFundResponse object with HTTP response. */ public static VirtualBankAccountSyncFundResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __transactionJson = JsonUtil.getObject(json, "transaction"); - if (__transactionJson != null) { - builder.transaction(Transaction.fromJson(__transactionJson)); + JsonObject __transactionObj = JsonUtil.getJsonObject(jsonObj, "transaction"); + if (__transactionObj != null) { + builder.transaction(Transaction.fromJson(__transactionObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/webhookEndpoint/WebhookEndpoint.java b/src/main/java/com/chargebee/v4/models/webhookEndpoint/WebhookEndpoint.java index 707a5650..2098ae14 100644 --- a/src/main/java/com/chargebee/v4/models/webhookEndpoint/WebhookEndpoint.java +++ b/src/main/java/com/chargebee/v4/models/webhookEndpoint/WebhookEndpoint.java @@ -8,6 +8,8 @@ package com.chargebee.v4.models.webhookEndpoint; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonArray; +import com.google.gson.JsonObject; import java.util.List; public class WebhookEndpoint { @@ -120,27 +122,34 @@ public static ChargebeeResponseSchemaType fromString(String value) { } public static WebhookEndpoint fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static WebhookEndpoint fromJson(JsonObject jsonObj) { WebhookEndpoint obj = new WebhookEndpoint(); - obj.id = JsonUtil.getString(json, "id"); + obj.id = JsonUtil.getString(jsonObj, "id"); - obj.name = JsonUtil.getString(json, "name"); + obj.name = JsonUtil.getString(jsonObj, "name"); - obj.url = JsonUtil.getString(json, "url"); + obj.url = JsonUtil.getString(jsonObj, "url"); - obj.sendCardResource = JsonUtil.getBoolean(json, "send_card_resource"); + obj.sendCardResource = JsonUtil.getBoolean(jsonObj, "send_card_resource"); - obj.disabled = JsonUtil.getBoolean(json, "disabled"); + obj.disabled = JsonUtil.getBoolean(jsonObj, "disabled"); - obj.primaryUrl = JsonUtil.getBoolean(json, "primary_url"); + obj.primaryUrl = JsonUtil.getBoolean(jsonObj, "primary_url"); - obj.apiVersion = ApiVersion.fromString(JsonUtil.getString(json, "api_version")); + obj.apiVersion = ApiVersion.fromString(JsonUtil.getString(jsonObj, "api_version")); obj.chargebeeResponseSchemaType = ChargebeeResponseSchemaType.fromString( - JsonUtil.getString(json, "chargebee_response_schema_type")); + JsonUtil.getString(jsonObj, "chargebee_response_schema_type")); - obj.enabledEvents = JsonUtil.parseArrayOfString(JsonUtil.getArray(json, "enabled_events")); + JsonArray __enabledEventsArr = JsonUtil.getJsonArray(jsonObj, "enabled_events"); + if (__enabledEventsArr != null) { + obj.enabledEvents = JsonUtil.parseArrayOfString(__enabledEventsArr); + } return obj; } diff --git a/src/main/java/com/chargebee/v4/models/webhookEndpoint/responses/WebhookEndpointCreateResponse.java b/src/main/java/com/chargebee/v4/models/webhookEndpoint/responses/WebhookEndpointCreateResponse.java index f01243d9..f8482cc0 100644 --- a/src/main/java/com/chargebee/v4/models/webhookEndpoint/responses/WebhookEndpointCreateResponse.java +++ b/src/main/java/com/chargebee/v4/models/webhookEndpoint/responses/WebhookEndpointCreateResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static WebhookEndpointCreateResponse fromJson(String json) { /** Parse JSON response into WebhookEndpointCreateResponse object with HTTP response. */ public static WebhookEndpointCreateResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __webhookEndpointJson = JsonUtil.getObject(json, "webhook_endpoint"); - if (__webhookEndpointJson != null) { - builder.webhookEndpoint(WebhookEndpoint.fromJson(__webhookEndpointJson)); + JsonObject __webhookEndpointObj = JsonUtil.getJsonObject(jsonObj, "webhook_endpoint"); + if (__webhookEndpointObj != null) { + builder.webhookEndpoint(WebhookEndpoint.fromJson(__webhookEndpointObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/webhookEndpoint/responses/WebhookEndpointDeleteResponse.java b/src/main/java/com/chargebee/v4/models/webhookEndpoint/responses/WebhookEndpointDeleteResponse.java index 221ce4eb..5244c634 100644 --- a/src/main/java/com/chargebee/v4/models/webhookEndpoint/responses/WebhookEndpointDeleteResponse.java +++ b/src/main/java/com/chargebee/v4/models/webhookEndpoint/responses/WebhookEndpointDeleteResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static WebhookEndpointDeleteResponse fromJson(String json) { /** Parse JSON response into WebhookEndpointDeleteResponse object with HTTP response. */ public static WebhookEndpointDeleteResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __webhookEndpointJson = JsonUtil.getObject(json, "webhook_endpoint"); - if (__webhookEndpointJson != null) { - builder.webhookEndpoint(WebhookEndpoint.fromJson(__webhookEndpointJson)); + JsonObject __webhookEndpointObj = JsonUtil.getJsonObject(jsonObj, "webhook_endpoint"); + if (__webhookEndpointObj != null) { + builder.webhookEndpoint(WebhookEndpoint.fromJson(__webhookEndpointObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/webhookEndpoint/responses/WebhookEndpointListResponse.java b/src/main/java/com/chargebee/v4/models/webhookEndpoint/responses/WebhookEndpointListResponse.java index 51d5ba78..52fc504d 100644 --- a/src/main/java/com/chargebee/v4/models/webhookEndpoint/responses/WebhookEndpointListResponse.java +++ b/src/main/java/com/chargebee/v4/models/webhookEndpoint/responses/WebhookEndpointListResponse.java @@ -6,6 +6,7 @@ import com.chargebee.v4.exceptions.ChargebeeException; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; import com.chargebee.v4.services.WebhookEndpointService; import com.chargebee.v4.models.webhookEndpoint.params.WebhookEndpointListParams; @@ -43,13 +44,13 @@ private WebhookEndpointListResponse( */ public static WebhookEndpointListResponse fromJson(String json) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(WebhookEndpointListItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "list"), WebhookEndpointListItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new WebhookEndpointListResponse(list, nextOffset, null, null, null); } catch (Exception e) { @@ -67,13 +68,13 @@ public static WebhookEndpointListResponse fromJson( WebhookEndpointListParams originalParams, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); List list = - JsonUtil.parseObjectArray(JsonUtil.getArray(json, "list")).stream() - .map(WebhookEndpointListItem::fromJson) - .collect(java.util.stream.Collectors.toList()); + JsonUtil.mapArray( + JsonUtil.getJsonArray(jsonObj, "list"), WebhookEndpointListItem::fromJson); - String nextOffset = JsonUtil.getString(json, "next_offset"); + String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); return new WebhookEndpointListResponse( list, nextOffset, service, originalParams, httpResponse); @@ -174,11 +175,15 @@ public WebhookEndpoint getWebhookEndpoint() { } public static WebhookEndpointListItem fromJson(String json) { + return fromJson(JsonUtil.parse(json)); + } + + public static WebhookEndpointListItem fromJson(JsonObject jsonObj) { WebhookEndpointListItem item = new WebhookEndpointListItem(); - String __webhookEndpointJson = JsonUtil.getObject(json, "webhook_endpoint"); - if (__webhookEndpointJson != null) { - item.webhookEndpoint = WebhookEndpoint.fromJson(__webhookEndpointJson); + JsonObject __webhookEndpointObj = JsonUtil.getJsonObject(jsonObj, "webhook_endpoint"); + if (__webhookEndpointObj != null) { + item.webhookEndpoint = WebhookEndpoint.fromJson(__webhookEndpointObj); } return item; diff --git a/src/main/java/com/chargebee/v4/models/webhookEndpoint/responses/WebhookEndpointRetrieveResponse.java b/src/main/java/com/chargebee/v4/models/webhookEndpoint/responses/WebhookEndpointRetrieveResponse.java index e8eec404..6251f836 100644 --- a/src/main/java/com/chargebee/v4/models/webhookEndpoint/responses/WebhookEndpointRetrieveResponse.java +++ b/src/main/java/com/chargebee/v4/models/webhookEndpoint/responses/WebhookEndpointRetrieveResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static WebhookEndpointRetrieveResponse fromJson(String json) { /** Parse JSON response into WebhookEndpointRetrieveResponse object with HTTP response. */ public static WebhookEndpointRetrieveResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __webhookEndpointJson = JsonUtil.getObject(json, "webhook_endpoint"); - if (__webhookEndpointJson != null) { - builder.webhookEndpoint(WebhookEndpoint.fromJson(__webhookEndpointJson)); + JsonObject __webhookEndpointObj = JsonUtil.getJsonObject(jsonObj, "webhook_endpoint"); + if (__webhookEndpointObj != null) { + builder.webhookEndpoint(WebhookEndpoint.fromJson(__webhookEndpointObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/models/webhookEndpoint/responses/WebhookEndpointUpdateResponse.java b/src/main/java/com/chargebee/v4/models/webhookEndpoint/responses/WebhookEndpointUpdateResponse.java index 0770f0eb..89de9d2f 100644 --- a/src/main/java/com/chargebee/v4/models/webhookEndpoint/responses/WebhookEndpointUpdateResponse.java +++ b/src/main/java/com/chargebee/v4/models/webhookEndpoint/responses/WebhookEndpointUpdateResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; /** @@ -27,11 +28,12 @@ public static WebhookEndpointUpdateResponse fromJson(String json) { /** Parse JSON response into WebhookEndpointUpdateResponse object with HTTP response. */ public static WebhookEndpointUpdateResponse fromJson(String json, Response httpResponse) { try { + JsonObject jsonObj = JsonUtil.parse(json); Builder builder = builder(); - String __webhookEndpointJson = JsonUtil.getObject(json, "webhook_endpoint"); - if (__webhookEndpointJson != null) { - builder.webhookEndpoint(WebhookEndpoint.fromJson(__webhookEndpointJson)); + JsonObject __webhookEndpointObj = JsonUtil.getJsonObject(jsonObj, "webhook_endpoint"); + if (__webhookEndpointObj != null) { + builder.webhookEndpoint(WebhookEndpoint.fromJson(__webhookEndpointObj)); } builder.httpResponse(httpResponse); From a2197c4a0f94eaf418d8eb8fc62ca07626c5aa4a Mon Sep 17 00:00:00 2001 From: cb-karthikp Date: Tue, 24 Feb 2026 13:12:09 +0530 Subject: [PATCH 2/6] add tests --- .../v4/internal/CustomFieldsTest.java | 155 ++++++++ .../v4/internal/CustomerParserTest.java | 275 +++++++++++++ .../v4/internal/EventParserTest.java | 231 +++++++++++ .../v4/internal/InvoiceParserTest.java | 233 +++++++++++ .../v4/internal/ItemPriceParserTest.java | 109 ++++++ .../chargebee/v4/internal/JsonUtilTest.java | 370 +++++++++++++++++- .../v4/internal/ListResponseParserTest.java | 293 ++++++++++++++ .../v4/internal/SubscriptionParserTest.java | 153 ++++++++ .../v4/internal/TransactionParserTest.java | 109 ++++++ src/test/resources/fixtures/customer.json | 35 ++ .../resources/fixtures/customer_list.json | 103 +++++ src/test/resources/fixtures/events.json | 200 ++++++++++ src/test/resources/fixtures/invoice.json | 115 ++++++ src/test/resources/fixtures/itemPrices.json | 21 + src/test/resources/fixtures/subscription.json | 48 +++ src/test/resources/fixtures/transaction.json | 24 ++ 16 files changed, 2457 insertions(+), 17 deletions(-) create mode 100644 src/test/java/com/chargebee/v4/internal/CustomFieldsTest.java create mode 100644 src/test/java/com/chargebee/v4/internal/CustomerParserTest.java create mode 100644 src/test/java/com/chargebee/v4/internal/EventParserTest.java create mode 100644 src/test/java/com/chargebee/v4/internal/InvoiceParserTest.java create mode 100644 src/test/java/com/chargebee/v4/internal/ItemPriceParserTest.java create mode 100644 src/test/java/com/chargebee/v4/internal/ListResponseParserTest.java create mode 100644 src/test/java/com/chargebee/v4/internal/SubscriptionParserTest.java create mode 100644 src/test/java/com/chargebee/v4/internal/TransactionParserTest.java create mode 100644 src/test/resources/fixtures/customer.json create mode 100644 src/test/resources/fixtures/customer_list.json create mode 100644 src/test/resources/fixtures/events.json create mode 100644 src/test/resources/fixtures/invoice.json create mode 100644 src/test/resources/fixtures/itemPrices.json create mode 100644 src/test/resources/fixtures/subscription.json create mode 100644 src/test/resources/fixtures/transaction.json diff --git a/src/test/java/com/chargebee/v4/internal/CustomFieldsTest.java b/src/test/java/com/chargebee/v4/internal/CustomFieldsTest.java new file mode 100644 index 00000000..d65529be --- /dev/null +++ b/src/test/java/com/chargebee/v4/internal/CustomFieldsTest.java @@ -0,0 +1,155 @@ +package com.chargebee.v4.internal; + +import com.chargebee.v4.models.customer.Customer; +import com.chargebee.v4.models.invoice.Invoice; +import com.chargebee.v4.models.subscription.Subscription; +import org.junit.jupiter.api.*; + +import static org.junit.jupiter.api.Assertions.*; + +/** + * Verifies that model fromJson correctly extracts root-level custom fields + * (cf_*) while ignoring those buried inside nested objects and arrays. + * Tests multiple models to ensure the shared extractCustomFields pattern works generically. + */ +@DisplayName("Custom Fields (cf_*) extraction across models") +class CustomFieldsTest { + + private static final String NESTED_JSON_TEMPLATE = "{" + + "\"id\": \"%s\"," + + "\"billing_address\": {" + + " \"first_name\": \"John\"," + + " \"cf_addr_note\": \"should not leak\"" + + "}," + + "\"line_items\": [{" + + " \"id\": \"li_1\"," + + " \"cf_line_note\": \"should not leak either\"" + + "}]," + + "\"cf_root_field\": \"extracted\"" + + "}"; + + // ========== Invoice ========== + @Nested + @DisplayName("Invoice") + class InvoiceTests { + + @Test void rootCustomFields() { + String json = "{\"id\": \"inv_1\", \"status\": \"paid\"," + + "\"cf_department\": \"engineering\"," + + "\"cf_cost_center\": \"CC-100\"," + + "\"cf_notes\": \"rush order\"}"; + Invoice inv = Invoice.fromJson(json); + assertEquals("inv_1", inv.getId()); + assertEquals("engineering", inv.getCustomField("cf_department")); + assertEquals("CC-100", inv.getCustomField("cf_cost_center")); + assertEquals("rush order", inv.getCustomField("cf_notes")); + assertEquals(3, inv.getCustomFields().size()); + } + + @Test void nestedCfFieldsNotLeaked() { + Invoice inv = Invoice.fromJson(String.format(NESTED_JSON_TEMPLATE, "inv_1")); + assertEquals("extracted", inv.getCustomField("cf_root_field")); + assertNull(inv.getCustomField("cf_addr_note")); + assertNull(inv.getCustomField("cf_line_note")); + assertEquals(1, inv.getCustomFields().size()); + } + + @Test void emptyWhenNoCfPresent() { + Invoice inv = Invoice.fromJson("{\"id\": \"inv_1\", \"status\": \"paid\"}"); + assertNotNull(inv.getCustomFields()); + assertTrue(inv.getCustomFields().isEmpty()); + } + + @Test void rootCfWinsSameKeyAtNested() { + String json = "{\"id\": \"inv_1\"," + + "\"billing_address\": {\"cf_priority\": \"nested\"}," + + "\"cf_priority\": \"root\"}"; + Invoice inv = Invoice.fromJson(json); + assertEquals("root", inv.getCustomField("cf_priority")); + assertEquals(1, inv.getCustomFields().size()); + } + } + + // ========== Customer ========== + @Nested + @DisplayName("Customer") + class CustomerTests { + + @Test void rootCustomFields() { + String json = "{\"id\": \"cust_1\", \"first_name\": \"Jane\"," + + "\"cf_tier\": \"gold\", \"cf_region\": \"APAC\"}"; + Customer cust = Customer.fromJson(json); + assertEquals("cust_1", cust.getId()); + assertEquals("gold", cust.getCustomField("cf_tier")); + assertEquals("APAC", cust.getCustomField("cf_region")); + assertEquals(2, cust.getCustomFields().size()); + } + + @Test void nestedCfFieldsNotLeaked() { + String json = "{\"id\": \"cust_1\"," + + "\"billing_address\": {\"cf_addr_tag\": \"nested\"}," + + "\"cf_visible\": \"yes\"}"; + Customer cust = Customer.fromJson(json); + assertEquals("yes", cust.getCustomField("cf_visible")); + assertNull(cust.getCustomField("cf_addr_tag")); + } + + @Test void emptyWhenNoCfPresent() { + Customer cust = Customer.fromJson("{\"id\": \"cust_1\"}"); + assertNotNull(cust.getCustomFields()); + assertTrue(cust.getCustomFields().isEmpty()); + } + } + + // ========== Subscription ========== + @Nested + @DisplayName("Subscription") + class SubscriptionTests { + + @Test void rootCustomFields() { + String json = "{\"id\": \"sub_1\", \"status\": \"active\"," + + "\"cf_channel\": \"web\", \"cf_campaign_id\": \"camp_42\"}"; + Subscription sub = Subscription.fromJson(json); + assertEquals("sub_1", sub.getId()); + assertEquals("web", sub.getCustomField("cf_channel")); + assertEquals("camp_42", sub.getCustomField("cf_campaign_id")); + assertEquals(2, sub.getCustomFields().size()); + } + + @Test void nestedCfFieldsNotLeaked() { + String json = "{\"id\": \"sub_1\"," + + "\"subscription_items\": [{\"item_price_id\": \"p1\", \"cf_item_tag\": \"nested\"}]," + + "\"cf_plan_note\": \"visible\"}"; + Subscription sub = Subscription.fromJson(json); + assertEquals("visible", sub.getCustomField("cf_plan_note")); + assertNull(sub.getCustomField("cf_item_tag")); + assertEquals(1, sub.getCustomFields().size()); + } + + @Test void emptyWhenNoCfPresent() { + Subscription sub = Subscription.fromJson("{\"id\": \"sub_1\"}"); + assertNotNull(sub.getCustomFields()); + assertTrue(sub.getCustomFields().isEmpty()); + } + } + + // ========== Consent Fields (Customer-specific cs_*) ========== + @Nested + @DisplayName("Consent Fields (cs_*) - Customer") + class ConsentFieldsTests { + + @Test void rootConsentFields() { + String json = "{\"id\": \"cust_1\"," + + "\"cs_marketing\": true, \"cs_analytics\": false}"; + Customer cust = Customer.fromJson(json); + assertEquals(true, cust.getConsentFieldAsBoolean("cs_marketing")); + assertEquals(false, cust.getConsentFieldAsBoolean("cs_analytics")); + } + + @Test void emptyWhenNoCsPresent() { + Customer cust = Customer.fromJson("{\"id\": \"cust_1\"}"); + assertNotNull(cust.getConsentFields()); + assertTrue(cust.getConsentFields().isEmpty()); + } + } +} diff --git a/src/test/java/com/chargebee/v4/internal/CustomerParserTest.java b/src/test/java/com/chargebee/v4/internal/CustomerParserTest.java new file mode 100644 index 00000000..c40ff7ab --- /dev/null +++ b/src/test/java/com/chargebee/v4/internal/CustomerParserTest.java @@ -0,0 +1,275 @@ +package com.chargebee.v4.internal; + +import com.chargebee.v4.models.customer.Customer; +import com.chargebee.v4.models.customer.Customer.BillingAddress; +import org.junit.jupiter.api.*; + +import java.io.IOException; +import java.io.InputStream; +import java.nio.charset.StandardCharsets; +import java.sql.Timestamp; + +import static org.junit.jupiter.api.Assertions.*; + +@DisplayName("Customer JSON parsing") +class CustomerParserTest { + + private static Customer customer; + + @BeforeAll + static void loadFixture() throws IOException { + String customerJson; + try (InputStream is = CustomerParserTest.class.getResourceAsStream("/fixtures/customer.json")) { + assertNotNull(is, "fixtures/customer.json not found on classpath"); + customerJson = new String(is.readAllBytes(), StandardCharsets.UTF_8); + } + customer = Customer.fromJson(customerJson); + } + + @Nested + @DisplayName("String fields") + class StringFields { + + @Test void id() { + assertEquals("__test__KyVnHhSBWl7eY2bl", customer.getId()); + } + + @Test void firstName() { + assertEquals("John", customer.getFirstName()); + } + + @Test void lastName() { + assertEquals("Doe", customer.getLastName()); + } + + @Test void email() { + assertEquals("john@test.com", customer.getEmail()); + } + + @Test void locale() { + assertEquals("fr-CA", customer.getLocale()); + } + + @Test void preferredCurrencyCode() { + assertEquals("USD", customer.getPreferredCurrencyCode()); + } + } + + @Nested + @DisplayName("Boolean fields") + class BooleanFields { + + @Test void allowDirectDebit() { + assertEquals(false, customer.getAllowDirectDebit()); + } + + @Test void deleted() { + assertEquals(false, customer.getDeleted()); + } + } + + @Nested + @DisplayName("Integer fields") + class IntegerFields { + + @Test void netTermDays() { + assertEquals(0, customer.getNetTermDays()); + } + } + + @Nested + @DisplayName("Long fields") + class LongFields { + + @Test void resourceVersion() { + assertEquals(1517505731000L, customer.getResourceVersion()); + } + + @Test void promotionalCredits() { + assertEquals(0L, customer.getPromotionalCredits()); + } + + @Test void unbilledCharges() { + assertEquals(0L, customer.getUnbilledCharges()); + } + + @Test void refundableCredits() { + assertEquals(0L, customer.getRefundableCredits()); + } + + @Test void excessPayments() { + assertEquals(0L, customer.getExcessPayments()); + } + } + + @Nested + @DisplayName("Enum fields") + class EnumFields { + + @Test void autoCollection() { + assertEquals(Customer.AutoCollection.ON, customer.getAutoCollection()); + } + + @Test void piiCleared() { + assertEquals(Customer.PiiCleared.ACTIVE, customer.getPiiCleared()); + } + + @Test void taxability() { + assertEquals(Customer.Taxability.TAXABLE, customer.getTaxability()); + } + } + + @Nested + @DisplayName("Timestamp fields") + class TimestampFields { + + @Test void createdAt() { + assertEquals(new Timestamp(1517505731L * 1000), customer.getCreatedAt()); + } + + @Test void updatedAt() { + assertEquals(new Timestamp(1517505731L * 1000), customer.getUpdatedAt()); + } + } + + @Nested + @DisplayName("Absent fields parse as null") + class AbsentFields { + + @Test void phone() { + assertNull(customer.getPhone()); + } + + @Test void company() { + assertNull(customer.getCompany()); + } + + @Test void vatNumber() { + assertNull(customer.getVatNumber()); + } + + @Test void createdFromIp() { + assertNull(customer.getCreatedFromIp()); + } + + @Test void billingDate() { + assertNull(customer.getBillingDate()); + } + + @Test void channel() { + assertEquals(Customer.Channel._UNKNOWN, customer.getChannel()); + } + + @Test void fraudFlag() { + assertEquals(Customer.FraudFlag._UNKNOWN, customer.getFraudFlag()); + } + + @Test void paymentMethod() { + assertNull(customer.getPaymentMethod()); + } + + @Test void relationship() { + assertNull(customer.getRelationship()); + } + } + + @Nested + @DisplayName("Billing address (nested object)") + class BillingAddressTests { + + @Test void billingAddressNotNull() { + assertNotNull(customer.getBillingAddress()); + } + + @Test void city() { + assertEquals("Walnut", customer.getBillingAddress().getCity()); + } + + @Test void country() { + assertEquals("US", customer.getBillingAddress().getCountry()); + } + + @Test void billingFirstName() { + assertEquals("John", customer.getBillingAddress().getFirstName()); + } + + @Test void billingLastName() { + assertEquals("Mike", customer.getBillingAddress().getLastName()); + } + + @Test void line1() { + assertEquals("PO Box 9999", customer.getBillingAddress().getLine1()); + } + + @Test void state() { + assertEquals("California", customer.getBillingAddress().getState()); + } + + @Test void stateCode() { + assertEquals("CA", customer.getBillingAddress().getStateCode()); + } + + @Test void zip() { + assertEquals("91789", customer.getBillingAddress().getZip()); + } + + @Test void validationStatus() { + assertEquals( + BillingAddress.ValidationStatus.NOT_VALIDATED, + customer.getBillingAddress().getValidationStatus()); + } + + @Test void absentLine2() { + assertNull(customer.getBillingAddress().getLine2()); + } + + @Test void absentLine3() { + assertNull(customer.getBillingAddress().getLine3()); + } + } + + @Nested + @DisplayName("Empty collections for absent arrays") + class EmptyCollections { + + @Test void referralUrls() { + assertNotNull(customer.getReferralUrls()); + assertTrue(customer.getReferralUrls().isEmpty()); + } + + @Test void contacts() { + assertNotNull(customer.getContacts()); + assertTrue(customer.getContacts().isEmpty()); + } + + @Test void balances() { + assertNotNull(customer.getBalances()); + assertTrue(customer.getBalances().isEmpty()); + } + + @Test void entityIdentifiers() { + assertNotNull(customer.getEntityIdentifiers()); + assertTrue(customer.getEntityIdentifiers().isEmpty()); + } + + @Test void taxProvidersFields() { + assertNotNull(customer.getTaxProvidersFields()); + assertTrue(customer.getTaxProvidersFields().isEmpty()); + } + } + + @Nested + @DisplayName("Custom and consent fields") + class DynamicFields { + + @Test void customFieldsEmpty() { + assertNotNull(customer.getCustomFields()); + assertTrue(customer.getCustomFields().isEmpty()); + } + + @Test void consentFieldsEmpty() { + assertNotNull(customer.getConsentFields()); + assertTrue(customer.getConsentFields().isEmpty()); + } + } +} diff --git a/src/test/java/com/chargebee/v4/internal/EventParserTest.java b/src/test/java/com/chargebee/v4/internal/EventParserTest.java new file mode 100644 index 00000000..59d92d6f --- /dev/null +++ b/src/test/java/com/chargebee/v4/internal/EventParserTest.java @@ -0,0 +1,231 @@ +package com.chargebee.v4.internal; + +import com.chargebee.v4.models.card.Card; +import com.chargebee.v4.models.customer.Customer; +import com.chargebee.v4.models.event.Event; +import com.chargebee.v4.models.event.Event.*; +import com.chargebee.v4.models.invoice.Invoice; +import com.chargebee.v4.models.subscription.Subscription; +import org.junit.jupiter.api.*; + +import java.io.IOException; +import java.io.InputStream; +import java.nio.charset.StandardCharsets; +import java.sql.Timestamp; +import java.util.Map; + +import static org.junit.jupiter.api.Assertions.*; + +@DisplayName("Event JSON parsing") +class EventParserTest { + + private static Event event; + + @BeforeAll + static void loadFixture() throws IOException { + String raw; + try (InputStream is = EventParserTest.class.getResourceAsStream("/fixtures/events.json")) { + assertNotNull(is, "fixtures/events.json not found on classpath"); + raw = new String(is.readAllBytes(), StandardCharsets.UTF_8); + } + String eventJson = JsonUtil.getObject(raw, "event"); + assertNotNull(eventJson, "could not extract 'event' wrapper from fixture"); + event = Event.fromJson(eventJson); + } + + @Nested + @DisplayName("Top-level scalar fields") + class TopLevelFields { + + @Test void parsesStringFields() { + assertEquals("ev_16BPgETyVrQbiGhA", event.getId()); + assertEquals("sarah@sarah.com", event.getUser()); + } + + @Test void parsesEnumFields() { + assertEquals(Event.Source.ADMIN_CONSOLE, event.getSource()); + assertEquals(Event.EventType.SUBSCRIPTION_CREATED, event.getEventType()); + assertEquals(Event.ApiVersion.V2, event.getApiVersion()); + assertEquals(Event.WebhookStatus.NOT_CONFIGURED, event.getWebhookStatus()); + } + + @Test void parsesTimestampFields() { + assertEquals(new Timestamp(1702645601L * 1000), event.getOccurredAt()); + } + + @Test void absentFieldsAreNull() { + assertNull(event.getOriginUser()); + assertNull(event.getWebhookFailureReason()); + } + } + + @Nested + @DisplayName("Content — embedded subscription") + class ContentSubscriptionTests { + + @Test void parsesSubscription() { + Map content = event.getContent(); + String subJson = (String) content.get("subscription"); + assertNotNull(subJson); + Subscription sub = Subscription.fromJson(subJson); + + assertEquals("16BPgETyVrQVHGh1", sub.getId()); + assertEquals("sarah", sub.getCustomerId()); + assertEquals("INR", sub.getCurrencyCode()); + assertEquals(Subscription.Status.ACTIVE, sub.getStatus()); + assertEquals(Subscription.Channel.WEB, sub.getChannel()); + assertEquals(1, sub.getBillingPeriod()); + assertEquals(Subscription.BillingPeriodUnit.MONTH, sub.getBillingPeriodUnit()); + assertEquals(false, sub.getHasScheduledChanges()); + assertEquals(false, sub.getDeleted()); + assertEquals(0L, sub.getMrr()); + assertEquals(0, sub.getDueInvoicesCount()); + assertEquals("16CQtCTrgrYwi9n2E", sub.getBusinessEntityId()); + assertEquals(new Timestamp(1702645601L * 1000), sub.getCreatedAt()); + assertEquals(new Timestamp(1702578600L * 1000), sub.getStartedAt()); + assertEquals(new Timestamp(1702578600L * 1000), sub.getActivatedAt()); + + assertNotNull(sub.getSubscriptionItems()); + assertEquals(1, sub.getSubscriptionItems().size()); + Subscription.SubscriptionItems item = sub.getSubscriptionItems().get(0); + assertEquals("cross-train-advanced-INR-1_MONTH", item.getItemPriceId()); + assertEquals(Subscription.SubscriptionItems.ItemType.PLAN, item.getItemType()); + assertEquals(1, item.getQuantity()); + assertEquals(11667L, item.getUnitPrice()); + assertEquals(11667L, item.getAmount()); + } + } + + @Nested + @DisplayName("Content — embedded customer") + class ContentCustomerTests { + + @Test void parsesCustomer() { + Map content = event.getContent(); + String custJson = (String) content.get("customer"); + assertNotNull(custJson); + Customer cust = Customer.fromJson(custJson); + + assertEquals("sarah", cust.getId()); + assertEquals(Customer.AutoCollection.ON, cust.getAutoCollection()); + assertEquals(0, cust.getNetTermDays()); + assertEquals(false, cust.getAllowDirectDebit()); + assertEquals(Customer.Taxability.TAXABLE, cust.getTaxability()); + assertEquals(Customer.PiiCleared.ACTIVE, cust.getPiiCleared()); + assertEquals(Customer.Channel.WEB, cust.getChannel()); + assertEquals(Customer.CardStatus.VALID, cust.getCardStatus()); + assertEquals("INR", cust.getPreferredCurrencyCode()); + assertEquals(0L, cust.getPromotionalCredits()); + assertEquals(0L, cust.getRefundableCredits()); + assertEquals(0L, cust.getExcessPayments()); + assertEquals(0L, cust.getUnbilledCharges()); + assertEquals("pm_169vujTyVrL5fFDl", cust.getPrimaryPaymentSourceId()); + assertEquals(false, cust.getDeleted()); + assertEquals(true, cust.getAutoCloseInvoices()); + + assertNotNull(cust.getPaymentMethod()); + assertEquals(Customer.PaymentMethod.Type.CARD, cust.getPaymentMethod().getType()); + assertEquals(Customer.PaymentMethod.Gateway.CHARGEBEE, cust.getPaymentMethod().getGateway()); + assertEquals("gw_1mk51R4QrLmQtYMht", cust.getPaymentMethod().getGatewayAccountId()); + assertEquals(Customer.PaymentMethod.Status.VALID, cust.getPaymentMethod().getStatus()); + assertEquals("tok_169vujTyVrL5LFDk", cust.getPaymentMethod().getReferenceId()); + } + } + + @Nested + @DisplayName("Content — embedded card") + class ContentCardTests { + + @Test void parsesCard() { + Map content = event.getContent(); + String cardJson = (String) content.get("card"); + assertNotNull(cardJson); + Card card = Card.fromJson(cardJson); + + assertEquals("pm_169vujTyVrL5fFDl", card.getPaymentSourceId()); + assertEquals("boom", card.getCustomerId()); + assertEquals(Card.Status.VALID, card.getStatus()); + assertEquals(Card.Gateway.CHARGEBEE, card.getGateway()); + assertEquals("gw_1mk51R4QrLmQtYMht", card.getGatewayAccountId()); + assertEquals("411111", card.getIin()); + assertEquals("1111", card.getLast4()); + assertEquals(Card.CardType.VISA, card.getCardType()); + assertEquals(Card.FundingType.CREDIT, card.getFundingType()); + assertEquals(12, card.getExpiryMonth()); + assertEquals(2024, card.getExpiryYear()); + assertEquals("************1111", card.getMaskedNumber()); + assertEquals("10.0.0.1", card.getIpAddress()); + assertEquals(new Timestamp(1702645580L * 1000), card.getCreatedAt()); + assertEquals(new Timestamp(1702645580L * 1000), card.getUpdatedAt()); + assertEquals(1702645580740L, card.getResourceVersion()); + } + } + + @Nested + @DisplayName("Content — embedded invoice") + class ContentInvoiceTests { + + @Test void parsesInvoice() { + Map content = event.getContent(); + String invJson = (String) content.get("invoice"); + assertNotNull(invJson); + Invoice inv = Invoice.fromJson(invJson); + + assertEquals("203", inv.getId()); + assertEquals("boom", inv.getCustomerId()); + assertEquals("16BPgETyVrQVHGh1", inv.getSubscriptionId()); + assertEquals(true, inv.getRecurring()); + assertEquals(Invoice.Status.PAID, inv.getStatus()); + assertEquals(Invoice.PriceType.TAX_EXCLUSIVE, inv.getPriceType()); + assertEquals(Invoice.Channel.WEB, inv.getChannel()); + assertEquals("INR", inv.getCurrencyCode()); + assertEquals(11667L, inv.getTotal()); + assertEquals(11667L, inv.getAmountPaid()); + assertEquals(11667L, inv.getSubTotal()); + assertEquals(11667L, inv.getNewSalesAmount()); + assertEquals(0L, inv.getTax()); + assertEquals(0L, inv.getAmountDue()); + assertEquals(0L, inv.getWriteOffAmount()); + assertEquals(0L, inv.getCreditsApplied()); + assertEquals(true, inv.getFirstInvoice()); + assertEquals(false, inv.getIsGifted()); + assertEquals(true, inv.getTermFinalized()); + assertEquals(false, inv.getDeleted()); + assertEquals("16CQtCTrgrYwi9n2E", inv.getBusinessEntityId()); + + assertNotNull(inv.getLineItems()); + assertEquals(1, inv.getLineItems().size()); + Invoice.LineItems li = inv.getLineItems().get(0); + assertEquals("li_16BPgETyVrQWBGh3", li.getId()); + assertEquals(11667L, li.getAmount()); + assertEquals(Invoice.LineItems.EntityType.PLAN_ITEM_PRICE, li.getEntityType()); + assertEquals(Invoice.LineItems.TaxExemptReason.EXPORT, li.getTaxExemptReason()); + + assertNotNull(inv.getLinkedPayments()); + assertEquals(1, inv.getLinkedPayments().size()); + Invoice.LinkedPayments lp = inv.getLinkedPayments().get(0); + assertEquals("txn_16BPgETyVrQXVGh4", lp.getTxnId()); + assertEquals(11667L, lp.getAppliedAmount()); + assertEquals(Invoice.LinkedPayments.TxnStatus.SUCCESS, lp.getTxnStatus()); + + assertNotNull(inv.getNotes()); + assertEquals(1, inv.getNotes().size()); + } + } + + @Nested + @DisplayName("Webhooks array") + class WebhooksTests { + + @Test void parsesOneWebhook() { + assertNotNull(event.getWebhooks()); + assertEquals(1, event.getWebhooks().size()); + } + + @Test void webhookFields() { + Webhooks wh = event.getWebhooks().get(0); + assertEquals("whv2_Azz5aITsMVdKtVWV", wh.getId()); + assertEquals(Webhooks.WebhookStatus.NOT_APPLICABLE, wh.getWebhookStatus()); + } + } +} diff --git a/src/test/java/com/chargebee/v4/internal/InvoiceParserTest.java b/src/test/java/com/chargebee/v4/internal/InvoiceParserTest.java new file mode 100644 index 00000000..5b238645 --- /dev/null +++ b/src/test/java/com/chargebee/v4/internal/InvoiceParserTest.java @@ -0,0 +1,233 @@ +package com.chargebee.v4.internal; + +import com.chargebee.v4.models.invoice.Invoice; +import com.chargebee.v4.models.invoice.Invoice.*; +import org.junit.jupiter.api.*; + +import java.io.IOException; +import java.io.InputStream; +import java.math.BigDecimal; +import java.nio.charset.StandardCharsets; +import java.sql.Timestamp; + +import static org.junit.jupiter.api.Assertions.*; + +@DisplayName("Invoice JSON parsing") +class InvoiceParserTest { + + private static String invoiceJson; + private static Invoice invoice; + + @BeforeAll + static void loadFixture() throws IOException { + try (InputStream is = InvoiceParserTest.class.getResourceAsStream("/fixtures/invoice.json")) { + assertNotNull(is, "fixtures/invoice.json not found on classpath"); + invoiceJson = new String(is.readAllBytes(), StandardCharsets.UTF_8); + } + invoice = Invoice.fromJson(invoiceJson); + } + + @Nested + @DisplayName("Top-level scalar fields") + class TopLevelFields { + + @Test void parsesStringFields() { + assertEquals("__demo_inv__1", invoice.getId()); + assertEquals("__test__KyVkkWS1xLskm8", invoice.getCustomerId()); + assertEquals("USD", invoice.getCurrencyCode()); + } + + @Test void parsesBooleanFields() { + assertEquals(false, invoice.getRecurring()); + assertEquals(true, invoice.getFirstInvoice()); + assertEquals(false, invoice.getHasAdvanceCharges()); + assertEquals(true, invoice.getTermFinalized()); + assertEquals(false, invoice.getIsGifted()); + assertEquals(false, invoice.getDeleted()); + } + + @Test void parsesIntegerFields() { + assertEquals(0, invoice.getNetTermDays()); + } + + @Test void parsesLongFields() { + assertEquals(0L, invoice.getAmountAdjusted()); + assertEquals(0L, invoice.getAmountDue()); + assertEquals(2000L, invoice.getAmountPaid()); + assertEquals(0L, invoice.getAmountToCollect()); + assertEquals(0L, invoice.getCreditsApplied()); + assertEquals(2000L, invoice.getNewSalesAmount()); + assertEquals(0L, invoice.getRoundOffAmount()); + assertEquals(1517463750000L, invoice.getResourceVersion()); + assertEquals(2000L, invoice.getSubTotal()); + assertEquals(0L, invoice.getTax()); + assertEquals(2000L, invoice.getTotal()); + assertEquals(0L, invoice.getWriteOffAmount()); + } + + @Test void parsesBigDecimalFields() { + assertEquals(0, new BigDecimal("1").compareTo(invoice.getExchangeRate())); + } + + @Test void parsesEnumFields() { + assertEquals(Invoice.Status.PAID, invoice.getStatus()); + assertEquals(Invoice.PriceType.TAX_EXCLUSIVE, invoice.getPriceType()); + assertEquals(Invoice.Channel._UNKNOWN, invoice.getChannel()); + } + + @Test void parsesTimestampFields() { + assertEquals(new Timestamp(1517463749L * 1000), invoice.getDate()); + assertEquals(new Timestamp(1517463749L * 1000), invoice.getDueDate()); + assertEquals(new Timestamp(1517463750L * 1000), invoice.getPaidAt()); + assertEquals(new Timestamp(1517463750L * 1000), invoice.getUpdatedAt()); + } + + @Test void absentFieldsAreNull() { + assertNull(invoice.getSubscriptionId()); + assertNull(invoice.getPaymentOwner()); + assertNull(invoice.getPoNumber()); + assertNull(invoice.getVatNumber()); + assertNull(invoice.getVoidReasonCode()); + assertNull(invoice.getBusinessEntityId()); + assertNull(invoice.getStatementDescriptor()); + assertNull(invoice.getEinvoice()); + assertNull(invoice.getSiteDetailsAtCreation()); + assertNull(invoice.getTaxOrigin()); + } + } + + @Nested + @DisplayName("Billing address") + class BillingAddressTests { + + @Test void parsesAllFields() { + BillingAddress ba = invoice.getBillingAddress(); + assertNotNull(ba); + assertEquals("John", ba.getFirstName()); + assertEquals("Mathew", ba.getLastName()); + assertEquals(BillingAddress.ValidationStatus.NOT_VALIDATED, ba.getValidationStatus()); + } + + @Test void absentSubFieldsAreNull() { + BillingAddress ba = invoice.getBillingAddress(); + assertNull(ba.getCity()); + assertNull(ba.getCountry()); + assertNull(ba.getLine1()); + assertNull(ba.getZip()); + } + } + + @Nested + @DisplayName("Shipping address") + class ShippingAddressTests { + + @Test void parsesAllFields() { + ShippingAddress sa = invoice.getShippingAddress(); + assertNotNull(sa); + assertEquals("John", sa.getFirstName()); + assertEquals("Mathew", sa.getLastName()); + assertEquals("Walnut", sa.getCity()); + assertEquals("US", sa.getCountry()); + assertEquals("California", sa.getState()); + assertEquals("CA", sa.getStateCode()); + assertEquals("91789", sa.getZip()); + assertEquals(ShippingAddress.ValidationStatus.NOT_VALIDATED, sa.getValidationStatus()); + } + } + + @Nested + @DisplayName("Line items array") + class LineItemsTests { + + @Test void parsesTwoLineItems() { + assertNotNull(invoice.getLineItems()); + assertEquals(2, invoice.getLineItems().size()); + } + + @Test void firstLineItemFields() { + LineItems li = invoice.getLineItems().get(0); + assertEquals("li___test__KyVkkWS1xLt9LF", li.getId()); + assertEquals("__test__KyVkkWS1xLskm8", li.getCustomerId()); + assertEquals("SSL Charge USD Monthly", li.getDescription()); + assertEquals("ssl-charge-USD", li.getEntityId()); + assertEquals(2000L, li.getAmount()); + assertEquals(2000L, li.getUnitAmount()); + assertEquals(1, li.getQuantity()); + assertEquals(0L, li.getDiscountAmount()); + assertEquals(0L, li.getItemLevelDiscountAmount()); + assertEquals(0L, li.getTaxAmount()); + assertEquals(false, li.getIsTaxed()); + assertEquals(LineItems.PricingModel.FLAT_FEE, li.getPricingModel()); + assertEquals(LineItems.EntityType.CHARGE_ITEM_PRICE, li.getEntityType()); + assertEquals(LineItems.TaxExemptReason.TAX_NOT_CONFIGURED, li.getTaxExemptReason()); + assertEquals(new Timestamp(1517463749L * 1000), li.getDateFrom()); + assertEquals(new Timestamp(1517463749L * 1000), li.getDateTo()); + } + } + + @Nested + @DisplayName("Linked payments array") + class LinkedPaymentsTests { + + @Test void parsesTwoLinkedPayments() { + assertNotNull(invoice.getLinkedPayments()); + assertEquals(2, invoice.getLinkedPayments().size()); + } + + @Test void firstLinkedPaymentFields() { + LinkedPayments lp = invoice.getLinkedPayments().get(0); + assertEquals("txn___test__KyVkkWS1xLtFiG", lp.getTxnId()); + assertEquals(2000L, lp.getAppliedAmount()); + assertEquals(2000L, lp.getTxnAmount()); + assertEquals(LinkedPayments.TxnStatus.SUCCESS, lp.getTxnStatus()); + assertEquals(new Timestamp(1517463750L * 1000), lp.getAppliedAt()); + assertEquals(new Timestamp(1517463750L * 1000), lp.getTxnDate()); + } + + @Test void secondLinkedPaymentHasZeroAppliedAmount() { + LinkedPayments lp = invoice.getLinkedPayments().get(1); + assertEquals(0L, lp.getAppliedAmount()); + assertEquals(2000L, lp.getTxnAmount()); + } + } + + @Nested + @DisplayName("Empty/absent collections") + class EmptyCollections { + + @Test void emptyArraysAreEmptyLists() { + assertNotNull(invoice.getLineItemTiers()); + assertTrue(invoice.getLineItemTiers().isEmpty()); + + assertNotNull(invoice.getLineItemDiscounts()); + assertTrue(invoice.getLineItemDiscounts().isEmpty()); + + assertNotNull(invoice.getLineItemTaxes()); + assertTrue(invoice.getLineItemTaxes().isEmpty()); + + assertNotNull(invoice.getDiscounts()); + assertTrue(invoice.getDiscounts().isEmpty()); + + assertNotNull(invoice.getTaxes()); + assertTrue(invoice.getTaxes().isEmpty()); + + assertNotNull(invoice.getReferenceTransactions()); + assertTrue(invoice.getReferenceTransactions().isEmpty()); + + assertNotNull(invoice.getNotes()); + assertTrue(invoice.getNotes().isEmpty()); + } + } + + @Nested + @DisplayName("Custom fields") + class CustomFieldsTests { + + @Test void parsesCustomFields() { + assertNotNull(invoice.getCustomFields()); + assertEquals(2, invoice.getCustomFields().size()); + assertEquals("engineering", invoice.getCustomField("cf_department")); + assertEquals("CC-1042", invoice.getCustomField("cf_cost_center")); + } + } +} diff --git a/src/test/java/com/chargebee/v4/internal/ItemPriceParserTest.java b/src/test/java/com/chargebee/v4/internal/ItemPriceParserTest.java new file mode 100644 index 00000000..bfd536a0 --- /dev/null +++ b/src/test/java/com/chargebee/v4/internal/ItemPriceParserTest.java @@ -0,0 +1,109 @@ +package com.chargebee.v4.internal; + +import com.chargebee.v4.models.itemPrice.ItemPrice; +import org.junit.jupiter.api.*; + +import java.io.IOException; +import java.io.InputStream; +import java.nio.charset.StandardCharsets; +import java.sql.Timestamp; + +import static org.junit.jupiter.api.Assertions.*; + +@DisplayName("ItemPrice JSON parsing") +class ItemPriceParserTest { + + private static String itemPriceJson; + private static ItemPrice itemPrice; + + @BeforeAll + static void loadFixture() throws IOException { + try (InputStream is = ItemPriceParserTest.class.getResourceAsStream("/fixtures/itemPrices.json")) { + assertNotNull(is, "fixtures/itemPrices.json not found on classpath"); + itemPriceJson = new String(is.readAllBytes(), StandardCharsets.UTF_8); + } + itemPrice = ItemPrice.fromJson(itemPriceJson); + } + + @Nested + @DisplayName("Top-level scalar fields") + class TopLevelFields { + + @Test void parsesStringFields() { + assertEquals("silver-USD-monthly", itemPrice.getId()); + assertEquals("silver USD monthly", itemPrice.getName()); + assertEquals("silver USD", itemPrice.getExternalName()); + assertEquals("silver", itemPrice.getItemId()); + assertEquals("USD", itemPrice.getCurrencyCode()); + } + + @Test void parsesBooleanFields() { + assertEquals(true, itemPrice.getIsTaxable()); + } + + @Test void parsesIntegerFields() { + assertEquals(1, itemPrice.getPeriod()); + assertEquals(0, itemPrice.getFreeQuantity()); + } + + @Test void parsesLongFields() { + assertEquals(1000L, itemPrice.getPrice()); + assertEquals(1594106928574L, itemPrice.getResourceVersion()); + } + + @Test void parsesEnumFields() { + assertEquals(ItemPrice.Status.ACTIVE, itemPrice.getStatus()); + assertEquals(ItemPrice.PricingModel.PER_UNIT, itemPrice.getPricingModel()); + assertEquals(ItemPrice.PeriodUnit.MONTH, itemPrice.getPeriodUnit()); + assertEquals(ItemPrice.ItemType.PLAN, itemPrice.getItemType()); + assertEquals(ItemPrice.Channel._UNKNOWN, itemPrice.getChannel()); + } + + @Test void parsesTimestampFields() { + Timestamp ts = new Timestamp(1594106928L * 1000); + assertEquals(ts, itemPrice.getCreatedAt()); + assertEquals(ts, itemPrice.getUpdatedAt()); + } + + @Test void absentFieldsAreNull() { + assertNull(itemPrice.getDescription()); + assertNull(itemPrice.getItemFamilyId()); + assertNull(itemPrice.getPriceVariantId()); + assertNull(itemPrice.getPriceInDecimal()); + assertNull(itemPrice.getTrialPeriod()); + assertNull(itemPrice.getBillingCycles()); + assertNull(itemPrice.getShippingPeriod()); + assertNull(itemPrice.getArchivedAt()); + assertNull(itemPrice.getInvoiceNotes()); + assertNull(itemPrice.getBusinessEntityId()); + assertNull(itemPrice.getTaxDetail()); + assertNull(itemPrice.getAccountingDetail()); + assertNull(itemPrice.getDeleted()); + } + } + + @Nested + @DisplayName("Empty collections") + class EmptyCollections { + + @Test void emptyArraysAreEmptyLists() { + assertNotNull(itemPrice.getTiers()); + assertTrue(itemPrice.getTiers().isEmpty()); + + assertNotNull(itemPrice.getTaxProvidersFields()); + assertTrue(itemPrice.getTaxProvidersFields().isEmpty()); + } + } + + @Nested + @DisplayName("Custom fields") + class CustomFieldsTests { + + @Test void parsesCustomFields() { + assertNotNull(itemPrice.getCustomFields()); + assertEquals(2, itemPrice.getCustomFields().size()); + assertEquals("saas", itemPrice.getCustomField("cf_product_line")); + assertEquals("silver", itemPrice.getCustomField("cf_tier_level")); + } + } +} diff --git a/src/test/java/com/chargebee/v4/internal/JsonUtilTest.java b/src/test/java/com/chargebee/v4/internal/JsonUtilTest.java index 5fc09d30..25495514 100644 --- a/src/test/java/com/chargebee/v4/internal/JsonUtilTest.java +++ b/src/test/java/com/chargebee/v4/internal/JsonUtilTest.java @@ -1,11 +1,15 @@ package com.chargebee.v4.internal; +import com.google.gson.JsonArray; +import com.google.gson.JsonObject; import org.junit.jupiter.api.*; import java.math.BigDecimal; import java.sql.Timestamp; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import static org.junit.jupiter.api.Assertions.*; @@ -66,7 +70,7 @@ void shouldReturnNullForMissingKey() { @Test @DisplayName("should return null for null json") void shouldReturnNullForNullJson() { - assertNull(JsonUtil.getString(null, "key")); + assertNull(JsonUtil.getString((String) null, "key")); } @Test @@ -133,7 +137,7 @@ void shouldReturnNullForMissingKey() { @Test @DisplayName("should return null for null json") void shouldReturnNullForNullJson() { - assertNull(JsonUtil.getLong(null, "key")); + assertNull(JsonUtil.getLong((String) null, "key")); } @Test @@ -207,7 +211,7 @@ void shouldReturnNullForMissingKey() { @Test @DisplayName("should return null for null json") void shouldReturnNullForNullJson() { - assertNull(JsonUtil.getBoolean(null, "key")); + assertNull(JsonUtil.getBoolean((String) null, "key")); } } @@ -276,8 +280,8 @@ void shouldExtractSimpleNestedObject() { String json = "{\"customer\": {\"id\": \"cust_123\", \"name\": \"John\"}}"; String result = JsonUtil.getObject(json, "customer"); assertNotNull(result); - assertTrue(result.contains("\"id\": \"cust_123\"")); - assertTrue(result.contains("\"name\": \"John\"")); + assertEquals("cust_123", JsonUtil.getString(result, "id")); + assertEquals("John", JsonUtil.getString(result, "name")); } @Test @@ -345,7 +349,11 @@ void shouldExtractSimpleArrayOfStrings() { String json = "{\"tags\": [\"a\", \"b\", \"c\"]}"; String result = JsonUtil.getArray(json, "tags"); assertNotNull(result); - assertEquals("[\"a\", \"b\", \"c\"]", result); + List parsed = JsonUtil.parseArrayOfString(result); + assertEquals(3, parsed.size()); + assertEquals("a", parsed.get(0)); + assertEquals("b", parsed.get(1)); + assertEquals("c", parsed.get(2)); } @Test @@ -363,8 +371,10 @@ void shouldExtractArrayOfObjects() { assertNotNull(result); assertTrue(result.startsWith("[")); assertTrue(result.endsWith("]")); - assertTrue(result.contains("{\"id\": 1}")); - assertTrue(result.contains("{\"id\": 2}")); + List objects = JsonUtil.parseObjectArray(result); + assertEquals(2, objects.size()); + assertEquals(1, JsonUtil.getInteger(objects.get(0), "id")); + assertEquals(2, JsonUtil.getInteger(objects.get(1), "id")); } @Test @@ -461,9 +471,18 @@ void shouldReturnNullWhenNotArray() { @DisplayName("should handle multiple arrays in same object") void shouldHandleMultipleArrays() { String json = "{\"first\": [1, 2], \"second\": [3, 4], \"third\": [5, 6]}"; - assertEquals("[1, 2]", JsonUtil.getArray(json, "first")); - assertEquals("[3, 4]", JsonUtil.getArray(json, "second")); - assertEquals("[5, 6]", JsonUtil.getArray(json, "third")); + List first = JsonUtil.parseArrayOfInteger(JsonUtil.getArray(json, "first")); + assertEquals(2, first.size()); + assertEquals(1, first.get(0)); + assertEquals(2, first.get(1)); + + List second = JsonUtil.parseArrayOfInteger(JsonUtil.getArray(json, "second")); + assertEquals(2, second.size()); + assertEquals(3, second.get(0)); + + List third = JsonUtil.parseArrayOfInteger(JsonUtil.getArray(json, "third")); + assertEquals(2, third.size()); + assertEquals(5, third.get(0)); } @Test @@ -487,9 +506,9 @@ void shouldParseArrayOfSimpleObjects() { String arrayJson = "[{\"id\": 1}, {\"id\": 2}, {\"id\": 3}]"; List objects = JsonUtil.parseObjectArray(arrayJson); assertEquals(3, objects.size()); - assertTrue(objects.get(0).contains("\"id\": 1")); - assertTrue(objects.get(1).contains("\"id\": 2")); - assertTrue(objects.get(2).contains("\"id\": 3")); + assertEquals(1, JsonUtil.getInteger(objects.get(0), "id")); + assertEquals(2, JsonUtil.getInteger(objects.get(1), "id")); + assertEquals(3, JsonUtil.getInteger(objects.get(2), "id")); } @Test @@ -610,8 +629,8 @@ void shouldReturnEmptyListForEmptyArrays() { @Test @DisplayName("should return empty list for null input") void shouldReturnEmptyListForNull() { - assertTrue(JsonUtil.parseArrayOfString(null).isEmpty()); - assertTrue(JsonUtil.parseArrayOfInteger(null).isEmpty()); + assertTrue(JsonUtil.parseArrayOfString((String) null).isEmpty()); + assertTrue(JsonUtil.parseArrayOfInteger((String) null).isEmpty()); } } @@ -708,7 +727,7 @@ void shouldReturnEmptyMapForEmptyObject() { @Test @DisplayName("should return empty map for null") void shouldReturnEmptyMapForNull() { - Map map = JsonUtil.parseJsonObjectToMap(null); + Map map = JsonUtil.parseJsonObjectToMap((String) null); assertTrue(map.isEmpty()); } @@ -1033,5 +1052,322 @@ void shouldHandleFirstMatchForDuplicateKeys() { assertNotNull(result); } } + + // ========== Parse-Once (JsonObject-based) Tests ========== + @Nested + @DisplayName("Parse-Once JsonObject API Tests") + class ParseOnceTests { + + @Test + @DisplayName("parse should return JsonObject for valid JSON") + void parseShouldReturnJsonObject() { + JsonObject obj = JsonUtil.parse("{\"id\": \"sub_123\", \"amount\": 1000}"); + assertNotNull(obj); + assertEquals("sub_123", JsonUtil.getString(obj, "id")); + assertEquals(1000L, JsonUtil.getLong(obj, "amount")); + } + + @Test + @DisplayName("parse should return empty JsonObject for null/empty input") + void parseShouldHandleNullAndEmpty() { + assertNotNull(JsonUtil.parse(null)); + assertTrue(JsonUtil.parse(null).entrySet().isEmpty()); + assertNotNull(JsonUtil.parse("")); + assertNotNull(JsonUtil.parse(" ")); + } + + @Test + @DisplayName("all primitive extractors should work on JsonObject") + void allPrimitiveExtractorsOnJsonObject() { + String json = "{\"s\": \"hello\", \"i\": 42, \"l\": 9876543210, \"b\": true, \"d\": 3.14, \"bd\": 123.456, \"ts\": 1605530769}"; + JsonObject obj = JsonUtil.parse(json); + + assertEquals("hello", JsonUtil.getString(obj, "s")); + assertEquals(42, JsonUtil.getInteger(obj, "i")); + assertEquals(9876543210L, JsonUtil.getLong(obj, "l")); + assertTrue(JsonUtil.getBoolean(obj, "b")); + assertEquals(3.14, JsonUtil.getDouble(obj, "d"), 0.001); + assertEquals(new BigDecimal("123.456"), JsonUtil.getBigDecimal(obj, "bd")); + Timestamp ts = JsonUtil.getTimestamp(obj, "ts"); + assertNotNull(ts); + assertEquals(1605530769000L, ts.getTime()); + } + + @Test + @DisplayName("null and missing keys should return null on JsonObject") + void nullAndMissingKeysOnJsonObject() { + JsonObject obj = JsonUtil.parse("{\"name\": \"test\"}"); + assertNull(JsonUtil.getString(obj, "missing")); + assertNull(JsonUtil.getLong(obj, "missing")); + assertNull(JsonUtil.getInteger(obj, "missing")); + assertNull(JsonUtil.getBoolean(obj, "missing")); + assertNull(JsonUtil.getDouble(obj, "missing")); + assertNull(JsonUtil.getBigDecimal(obj, "missing")); + assertNull(JsonUtil.getTimestamp(obj, "missing")); + assertNull(JsonUtil.getJsonObject(obj, "missing")); + assertNull(JsonUtil.getJsonArray(obj, "missing")); + } + + @Test + @DisplayName("getJsonObject should extract nested objects without re-parsing") + void getJsonObjectShouldExtractNested() { + String json = "{\"customer\": {\"id\": \"cust_1\", \"email\": \"a@b.com\"}, \"amount\": 500}"; + JsonObject root = JsonUtil.parse(json); + + JsonObject customer = JsonUtil.getJsonObject(root, "customer"); + assertNotNull(customer); + assertEquals("cust_1", JsonUtil.getString(customer, "id")); + assertEquals("a@b.com", JsonUtil.getString(customer, "email")); + } + + @Test + @DisplayName("getJsonArray should extract arrays without re-parsing") + void getJsonArrayShouldExtractArrays() { + String json = "{\"items\": [{\"id\": \"item_1\"}, {\"id\": \"item_2\"}]}"; + JsonObject root = JsonUtil.parse(json); + + JsonArray items = JsonUtil.getJsonArray(root, "items"); + assertNotNull(items); + assertEquals(2, items.size()); + assertEquals("item_1", items.get(0).getAsJsonObject().get("id").getAsString()); + } + + @Test + @DisplayName("hasValue should work on JsonObject") + void hasValueOnJsonObject() { + JsonObject obj = JsonUtil.parse("{\"name\": \"test\", \"empty\": null}"); + assertTrue(JsonUtil.hasValue(obj, "name")); + assertFalse(JsonUtil.hasValue(obj, "empty")); + assertFalse(JsonUtil.hasValue(obj, "missing")); + } + + @Test + @DisplayName("mapArray should map JsonArray elements through fromJson-like function") + void mapArrayShouldWork() { + String json = "[{\"id\": \"a\"}, {\"id\": \"b\"}, {\"id\": \"c\"}]"; + JsonArray array = JsonUtil.parseToArray(json); + List ids = JsonUtil.mapArray(array, obj -> JsonUtil.getString(obj, "id")); + assertEquals(3, ids.size()); + assertEquals("a", ids.get(0)); + assertEquals("b", ids.get(1)); + assertEquals("c", ids.get(2)); + } + + @Test + @DisplayName("mapArray should return empty list for null array") + void mapArrayNullShouldReturnEmpty() { + List result = JsonUtil.mapArray(null, obj -> "x"); + assertNotNull(result); + assertTrue(result.isEmpty()); + } + + @Test + @DisplayName("mapArrayToMaps should convert array of objects to list of maps") + void mapArrayToMapsShouldWork() { + String json = "[{\"k1\": \"v1\"}, {\"k2\": 42}]"; + JsonArray array = JsonUtil.parseToArray(json); + List> maps = JsonUtil.mapArrayToMaps(array); + assertEquals(2, maps.size()); + assertEquals("v1", maps.get(0).get("k1")); + assertEquals(42L, maps.get(1).get("k2")); + } + + @Test + @DisplayName("parseArrayOfString with JsonArray should work") + void parseArrayOfStringWithJsonArray() { + JsonArray array = JsonUtil.parseToArray("[\"x\", \"y\", \"z\"]"); + List result = JsonUtil.parseArrayOfString(array); + assertEquals(3, result.size()); + assertEquals("x", result.get(0)); + } + + @Test + @DisplayName("parseArrayOfInteger with JsonArray should work") + void parseArrayOfIntegerWithJsonArray() { + JsonArray array = JsonUtil.parseToArray("[1, 2, 3]"); + List result = JsonUtil.parseArrayOfInteger(array); + assertEquals(3, result.size()); + assertEquals(1, result.get(0)); + } + + @Test + @DisplayName("parseArrayOfLong with JsonArray should work") + void parseArrayOfLongWithJsonArray() { + JsonArray array = JsonUtil.parseToArray("[1605530769000, 1605530770000]"); + List result = JsonUtil.parseArrayOfLong(array); + assertEquals(2, result.size()); + assertEquals(1605530769000L, result.get(0)); + } + + @Test + @DisplayName("parseArrayOfBoolean with JsonArray should work") + void parseArrayOfBooleanWithJsonArray() { + JsonArray array = JsonUtil.parseToArray("[true, false, true]"); + List result = JsonUtil.parseArrayOfBoolean(array); + assertEquals(3, result.size()); + assertTrue(result.get(0)); + assertFalse(result.get(1)); + } + + @Test + @DisplayName("parseArrayOfDouble with JsonArray should work") + void parseArrayOfDoubleWithJsonArray() { + JsonArray array = JsonUtil.parseToArray("[1.5, 2.7]"); + List result = JsonUtil.parseArrayOfDouble(array); + assertEquals(2, result.size()); + assertEquals(1.5, result.get(0), 0.001); + } + + @Test + @DisplayName("parseArrayOfBigDecimal with JsonArray should work") + void parseArrayOfBigDecimalWithJsonArray() { + JsonArray array = JsonUtil.parseToArray("[123.45, 678.90]"); + List result = JsonUtil.parseArrayOfBigDecimal(array); + assertEquals(2, result.size()); + } + + @Test + @DisplayName("parseJsonObjectToMap with JsonObject should work") + void parseJsonObjectToMapWithJsonObject() { + JsonObject obj = JsonUtil.parse("{\"name\": \"John\", \"age\": 30, \"active\": true}"); + Map map = JsonUtil.parseJsonObjectToMap(obj); + assertEquals("John", map.get("name")); + assertEquals(30L, map.get("age")); + assertEquals(true, map.get("active")); + } + + @Test + @DisplayName("getObject(JsonObject, key) should return JSON string") + void getObjectOnJsonObjectShouldReturnString() { + JsonObject obj = JsonUtil.parse("{\"meta\": {\"key\": \"val\"}}"); + String meta = JsonUtil.getObject(obj, "meta"); + assertNotNull(meta); + assertTrue(meta.contains("key")); + assertTrue(meta.contains("val")); + } + + @Test + @DisplayName("getArray(JsonObject, key) should return JSON string") + void getArrayOnJsonObjectShouldReturnString() { + JsonObject obj = JsonUtil.parse("{\"tags\": [\"a\", \"b\"]}"); + String tags = JsonUtil.getArray(obj, "tags"); + assertNotNull(tags); + assertTrue(tags.startsWith("[")); + assertTrue(tags.endsWith("]")); + } + } + + // ========== extractCustomFields / extractConsentFields Tests ========== + @Nested + @DisplayName("extractCustomFields / extractConsentFields Tests") + class ExtractFieldsTests { + + @Test + @DisplayName("extractCustomFields should extract cf_ prefixed fields") + void extractCustomFieldsShouldWork() { + JsonObject obj = JsonUtil.parse("{\"id\": \"sub_1\", \"cf_color\": \"blue\", \"cf_size\": \"large\", \"name\": \"test\"}"); + Set known = new HashSet<>(); + known.add("id"); + known.add("name"); + + Map cf = JsonUtil.extractCustomFields(obj, known); + assertEquals(2, cf.size()); + assertEquals("blue", cf.get("cf_color")); + assertEquals("large", cf.get("cf_size")); + } + + @Test + @DisplayName("extractCustomFields should handle null values") + void extractCustomFieldsNullValues() { + JsonObject obj = JsonUtil.parse("{\"cf_nullable\": null}"); + Map cf = JsonUtil.extractCustomFields(obj, new HashSet<>()); + assertEquals(1, cf.size()); + assertNull(cf.get("cf_nullable")); + } + + @Test + @DisplayName("extractCustomFields should exclude known fields even with cf_ prefix") + void extractCustomFieldsExcludesKnown() { + JsonObject obj = JsonUtil.parse("{\"cf_known\": \"val\"}"); + Set known = new HashSet<>(); + known.add("cf_known"); + Map cf = JsonUtil.extractCustomFields(obj, known); + assertTrue(cf.isEmpty()); + } + + @Test + @DisplayName("extractConsentFields should extract cs_ prefixed fields") + void extractConsentFieldsShouldWork() { + JsonObject obj = JsonUtil.parse("{\"id\": \"cust_1\", \"cs_marketing\": true, \"cs_analytics\": false}"); + Set known = new HashSet<>(); + known.add("id"); + + Map cs = JsonUtil.extractConsentFields(obj, known); + assertEquals(2, cs.size()); + assertEquals(true, cs.get("cs_marketing")); + assertEquals(false, cs.get("cs_analytics")); + } + } + + // ========== Parse-Once Real-World Scenario ========== + @Nested + @DisplayName("Parse-Once Real-World Scenario") + class ParseOnceRealWorld { + + @Test + @DisplayName("should parse complex response with single parse call") + void shouldParseComplexResponseWithSingleParse() { + String json = "{" + + "\"subscription\": {" + + "\"id\": \"sub_123\"," + + "\"status\": \"active\"," + + "\"customer_id\": \"cust_456\"," + + "\"mrr\": 5000," + + "\"created_at\": 1605530769," + + "\"deleted\": false," + + "\"exchange_rate\": 1.25," + + "\"subscription_items\": [" + + "{\"item_price_id\": \"price_1\", \"quantity\": 1}," + + "{\"item_price_id\": \"price_2\", \"quantity\": 2}" + + "]," + + "\"shipping_address\": {\"city\": \"NYC\", \"zip\": \"10001\"}," + + "\"coupons\": []," + + "\"meta_data\": {\"source\": \"api\"}" + + "}" + + "}"; + + JsonObject root = JsonUtil.parse(json); + JsonObject sub = JsonUtil.getJsonObject(root, "subscription"); + assertNotNull(sub); + + assertEquals("sub_123", JsonUtil.getString(sub, "id")); + assertEquals("active", JsonUtil.getString(sub, "status")); + assertEquals("cust_456", JsonUtil.getString(sub, "customer_id")); + assertEquals(5000L, JsonUtil.getLong(sub, "mrr")); + assertEquals(1605530769000L, JsonUtil.getTimestamp(sub, "created_at").getTime()); + assertFalse(JsonUtil.getBoolean(sub, "deleted")); + assertEquals(1.25, JsonUtil.getDouble(sub, "exchange_rate"), 0.001); + + JsonArray items = JsonUtil.getJsonArray(sub, "subscription_items"); + assertNotNull(items); + assertEquals(2, items.size()); + List itemIds = JsonUtil.mapArray(items, obj -> JsonUtil.getString(obj, "item_price_id")); + assertEquals("price_1", itemIds.get(0)); + assertEquals("price_2", itemIds.get(1)); + + JsonObject shipping = JsonUtil.getJsonObject(sub, "shipping_address"); + assertNotNull(shipping); + assertEquals("NYC", JsonUtil.getString(shipping, "city")); + + JsonArray coupons = JsonUtil.getJsonArray(sub, "coupons"); + assertNotNull(coupons); + assertEquals(0, coupons.size()); + + JsonObject metaObj = JsonUtil.getJsonObject(sub, "meta_data"); + assertNotNull(metaObj); + Map meta = JsonUtil.parseJsonObjectToMap(metaObj); + assertEquals("api", meta.get("source")); + } + } } diff --git a/src/test/java/com/chargebee/v4/internal/ListResponseParserTest.java b/src/test/java/com/chargebee/v4/internal/ListResponseParserTest.java new file mode 100644 index 00000000..7c59489f --- /dev/null +++ b/src/test/java/com/chargebee/v4/internal/ListResponseParserTest.java @@ -0,0 +1,293 @@ +package com.chargebee.v4.internal; + +import com.chargebee.v4.models.card.Card; +import com.chargebee.v4.models.customer.Customer; +import com.chargebee.v4.models.customer.responses.CustomerListResponse; +import com.chargebee.v4.models.customer.responses.CustomerListResponse.CustomerListItem; +import org.junit.jupiter.api.*; + +import java.io.IOException; +import java.io.InputStream; +import java.nio.charset.StandardCharsets; +import java.sql.Timestamp; +import java.util.List; + +import static org.junit.jupiter.api.Assertions.*; + +@DisplayName("List response JSON parsing") +class ListResponseParserTest { + + private static CustomerListResponse response; + + @BeforeAll + static void loadFixture() throws IOException { + String json; + try (InputStream is = ListResponseParserTest.class.getResourceAsStream("/fixtures/customer_list.json")) { + assertNotNull(is, "fixtures/customer_list.json not found on classpath"); + json = new String(is.readAllBytes(), StandardCharsets.UTF_8); + } + response = CustomerListResponse.fromJson(json); + } + + @Nested + @DisplayName("List structure") + class ListStructure { + + @Test void listNotNull() { + assertNotNull(response.getList()); + } + + @Test void listSize() { + assertEquals(3, response.getList().size()); + } + + @Test void eachItemHasCustomer() { + for (CustomerListItem item : response.getList()) { + assertNotNull(item.getCustomer(), "Each list item should have a customer"); + } + } + } + + @Nested + @DisplayName("Pagination") + class Pagination { + + @Test void nextOffsetParsed() { + assertEquals("[\"1605531050000\",\"3\"]", response.getNextOffset()); + } + + @Test void hasNextPageTrue() { + assertTrue(response.hasNextPage()); + } + + @Test void nextPageWithoutServiceThrows() { + assertThrows(UnsupportedOperationException.class, () -> response.nextPage()); + } + } + + @Nested + @DisplayName("First customer (cust_AzZhUGSP1)") + class FirstCustomer { + + private Customer customer() { + return response.getList().get(0).getCustomer(); + } + + @Test void id() { + assertEquals("cust_AzZhUGSP1", customer().getId()); + } + + @Test void firstName() { + assertEquals("John", customer().getFirstName()); + } + + @Test void lastName() { + assertEquals("Doe", customer().getLastName()); + } + + @Test void email() { + assertEquals("john@example.com", customer().getEmail()); + } + + @Test void autoCollection() { + assertEquals(Customer.AutoCollection.ON, customer().getAutoCollection()); + } + + @Test void createdAt() { + assertEquals(new Timestamp(1605530769L * 1000), customer().getCreatedAt()); + } + + @Test void resourceVersion() { + assertEquals(1605530800000L, customer().getResourceVersion()); + } + + @Test void deleted() { + assertFalse(customer().getDeleted()); + } + + @Test void preferredCurrencyCode() { + assertEquals("USD", customer().getPreferredCurrencyCode()); + } + + @Test void billingAddress() { + assertNotNull(customer().getBillingAddress()); + assertEquals("San Francisco", customer().getBillingAddress().getCity()); + assertEquals("CA", customer().getBillingAddress().getStateCode()); + assertEquals("94105", customer().getBillingAddress().getZip()); + } + + @Test void noCard() { + assertNull(response.getList().get(0).getCard()); + } + } + + @Nested + @DisplayName("Second customer (cust_AzZhUGSP2)") + class SecondCustomer { + + private Customer customer() { + return response.getList().get(1).getCustomer(); + } + + @Test void id() { + assertEquals("cust_AzZhUGSP2", customer().getId()); + } + + @Test void email() { + assertEquals("jane@example.com", customer().getEmail()); + } + + @Test void autoCollectionOff() { + assertEquals(Customer.AutoCollection.OFF, customer().getAutoCollection()); + } + + @Test void netTermDays() { + assertEquals(30, customer().getNetTermDays()); + } + + @Test void allowDirectDebit() { + assertTrue(customer().getAllowDirectDebit()); + } + + @Test void promotionalCredits() { + assertEquals(500L, customer().getPromotionalCredits()); + } + + @Test void noBillingAddress() { + assertNull(customer().getBillingAddress()); + } + + @Test void noCard() { + assertNull(response.getList().get(1).getCard()); + } + } + + @Nested + @DisplayName("Third customer with card (cust_AzZhUGSP3)") + class ThirdCustomerWithCard { + + private Customer customer() { + return response.getList().get(2).getCustomer(); + } + + private Card card() { + return response.getList().get(2).getCard(); + } + + @Test void customerId() { + assertEquals("cust_AzZhUGSP3", customer().getId()); + } + + @Test void taxabilityExempt() { + assertEquals(Customer.Taxability.EXEMPT, customer().getTaxability()); + } + + @Test void cardNotNull() { + assertNotNull(card()); + } + + @Test void cardLast4() { + assertEquals("1111", card().getLast4()); + } + + @Test void cardType() { + assertEquals(Card.CardType.VISA, card().getCardType()); + } + + @Test void cardExpiry() { + assertEquals(12, card().getExpiryMonth()); + assertEquals(2028, card().getExpiryYear()); + } + + @Test void cardMaskedNumber() { + assertEquals("************1111", card().getMaskedNumber()); + } + + @Test void cardCustomerId() { + assertEquals("cust_AzZhUGSP3", card().getCustomerId()); + } + } + + @Nested + @DisplayName("Edge cases") + class EdgeCases { + + @Test void emptyList() { + CustomerListResponse empty = CustomerListResponse.fromJson("{\"list\": []}"); + assertNotNull(empty.getList()); + assertTrue(empty.getList().isEmpty()); + assertNull(empty.getNextOffset()); + assertFalse(empty.hasNextPage()); + } + + @Test void nullNextOffset() { + CustomerListResponse resp = CustomerListResponse.fromJson( + "{\"list\": [{\"customer\": {\"id\": \"c1\", \"object\": \"customer\"}}], \"next_offset\": null}"); + assertEquals(1, resp.getList().size()); + assertNull(resp.getNextOffset()); + assertFalse(resp.hasNextPage()); + } + + @Test void missingNextOffset() { + CustomerListResponse resp = CustomerListResponse.fromJson( + "{\"list\": [{\"customer\": {\"id\": \"c1\", \"object\": \"customer\"}}]}"); + assertNull(resp.getNextOffset()); + assertFalse(resp.hasNextPage()); + } + + @Test void missingListKey() { + CustomerListResponse resp = CustomerListResponse.fromJson("{\"next_offset\": \"abc\"}"); + assertNotNull(resp.getList()); + assertTrue(resp.getList().isEmpty()); + assertEquals("abc", resp.getNextOffset()); + } + + @Test void emptyJsonObject() { + CustomerListResponse resp = CustomerListResponse.fromJson("{}"); + assertNotNull(resp.getList()); + assertTrue(resp.getList().isEmpty()); + assertNull(resp.getNextOffset()); + } + + @Test void singleItemNoCard() { + String json = "{\"list\": [{\"customer\": {\"id\": \"solo\", \"first_name\": \"Only\", \"email\": \"only@test.com\"}}]}"; + CustomerListResponse resp = CustomerListResponse.fromJson(json); + assertEquals(1, resp.getList().size()); + assertEquals("solo", resp.getList().get(0).getCustomer().getId()); + assertEquals("Only", resp.getList().get(0).getCustomer().getFirstName()); + assertNull(resp.getList().get(0).getCard()); + } + + @Test void listItemWithOnlyCard() { + String json = "{\"list\": [{\"card\": {\"status\": \"valid\", \"last4\": \"9999\"}}]}"; + CustomerListResponse resp = CustomerListResponse.fromJson(json); + assertEquals(1, resp.getList().size()); + assertNull(resp.getList().get(0).getCustomer()); + assertNotNull(resp.getList().get(0).getCard()); + assertEquals("9999", resp.getList().get(0).getCard().getLast4()); + } + + @Test void nextOffsetWithSpecialCharacters() { + String json = "{\"list\": [], \"next_offset\": \"[\\\"1605531050000\\\",\\\"100\\\"]\"}"; + CustomerListResponse resp = CustomerListResponse.fromJson(json); + assertEquals("[\"1605531050000\",\"100\"]", resp.getNextOffset()); + assertTrue(resp.hasNextPage()); + } + + @Test void largeList() { + StringBuilder json = new StringBuilder("{\"list\": ["); + for (int i = 0; i < 100; i++) { + if (i > 0) json.append(","); + json.append("{\"customer\": {\"id\": \"cust_").append(i) + .append("\", \"email\": \"user").append(i).append("@test.com\"}}"); + } + json.append("], \"next_offset\": \"offset_100\"}"); + + CustomerListResponse resp = CustomerListResponse.fromJson(json.toString()); + assertEquals(100, resp.getList().size()); + assertEquals("cust_0", resp.getList().get(0).getCustomer().getId()); + assertEquals("cust_99", resp.getList().get(99).getCustomer().getId()); + assertEquals("offset_100", resp.getNextOffset()); + } + } +} diff --git a/src/test/java/com/chargebee/v4/internal/SubscriptionParserTest.java b/src/test/java/com/chargebee/v4/internal/SubscriptionParserTest.java new file mode 100644 index 00000000..788b0057 --- /dev/null +++ b/src/test/java/com/chargebee/v4/internal/SubscriptionParserTest.java @@ -0,0 +1,153 @@ +package com.chargebee.v4.internal; + +import com.chargebee.v4.models.subscription.Subscription; +import com.chargebee.v4.models.subscription.Subscription.*; +import org.junit.jupiter.api.*; + +import java.io.IOException; +import java.io.InputStream; +import java.nio.charset.StandardCharsets; +import java.sql.Timestamp; + +import static org.junit.jupiter.api.Assertions.*; + +@DisplayName("Subscription JSON parsing") +class SubscriptionParserTest { + + private static String subscriptionJson; + private static Subscription subscription; + + @BeforeAll + static void loadFixture() throws IOException { + try (InputStream is = SubscriptionParserTest.class.getResourceAsStream("/fixtures/subscription.json")) { + assertNotNull(is, "fixtures/subscription.json not found on classpath"); + subscriptionJson = new String(is.readAllBytes(), StandardCharsets.UTF_8); + } + subscription = Subscription.fromJson(subscriptionJson); + } + + @Nested + @DisplayName("Top-level scalar fields") + class TopLevelFields { + + @Test void parsesStringFields() { + assertEquals("__test__8asukSOXe0W3SU", subscription.getId()); + assertEquals("USD", subscription.getCurrencyCode()); + assertEquals("__test__8asukSOXe0QYSR", subscription.getCustomerId()); + } + + @Test void parsesBooleanFields() { + assertEquals(false, subscription.getDeleted()); + assertEquals(false, subscription.getHasScheduledChanges()); + } + + @Test void parsesIntegerFields() { + assertEquals(1, subscription.getBillingPeriod()); + assertEquals(1, subscription.getRemainingBillingCycles()); + assertEquals(1, subscription.getDueInvoicesCount()); + } + + @Test void parsesLongFields() { + assertEquals(1612890938000L, subscription.getResourceVersion()); + assertEquals(0L, subscription.getMrr()); + assertEquals(1100L, subscription.getTotalDues()); + } + + @Test void parsesEnumFields() { + assertEquals(Subscription.Status.ACTIVE, subscription.getStatus()); + assertEquals(Subscription.BillingPeriodUnit.MONTH, subscription.getBillingPeriodUnit()); + assertEquals(Subscription.Channel._UNKNOWN, subscription.getChannel()); + } + + @Test void parsesTimestampFields() { + Timestamp ts = new Timestamp(1612890938L * 1000); + assertEquals(ts, subscription.getActivatedAt()); + assertEquals(ts, subscription.getCreatedAt()); + assertEquals(ts, subscription.getStartedAt()); + assertEquals(ts, subscription.getDueSince()); + assertEquals(ts, subscription.getUpdatedAt()); + assertEquals(new Timestamp(1612890938L * 1000), subscription.getCurrentTermStart()); + assertEquals(new Timestamp(1615310138L * 1000), subscription.getCurrentTermEnd()); + assertEquals(new Timestamp(1615310138L * 1000), subscription.getNextBillingAt()); + } + + @Test void absentFieldsAreNull() { + assertNull(subscription.getTrialStart()); + assertNull(subscription.getTrialEnd()); + assertNull(subscription.getPoNumber()); + assertNull(subscription.getCancelledAt()); + assertEquals(Subscription.CancelReason._UNKNOWN, subscription.getCancelReason()); + assertNull(subscription.getPaymentSourceId()); + assertNull(subscription.getShippingAddress()); + assertNull(subscription.getReferralInfo()); + assertNull(subscription.getContractTerm()); + assertNull(subscription.getBusinessEntityId()); + } + } + + @Nested + @DisplayName("Subscription items array") + class SubscriptionItemsTests { + + @Test void parsesTwoItems() { + assertNotNull(subscription.getSubscriptionItems()); + assertEquals(2, subscription.getSubscriptionItems().size()); + } + + @Test void firstItemIsPlan() { + SubscriptionItems item = subscription.getSubscriptionItems().get(0); + assertEquals("basic-USD", item.getItemPriceId()); + assertEquals(SubscriptionItems.ItemType.PLAN, item.getItemType()); + assertEquals(1, item.getQuantity()); + assertEquals(1000L, item.getUnitPrice()); + assertEquals(1000L, item.getAmount()); + assertEquals(0, item.getFreeQuantity()); + assertEquals(1, item.getBillingCycles()); + } + + @Test void secondItemIsAddon() { + SubscriptionItems item = subscription.getSubscriptionItems().get(1); + assertEquals("addon-USD", item.getItemPriceId()); + assertEquals(SubscriptionItems.ItemType.ADDON, item.getItemType()); + assertEquals(1, item.getQuantity()); + assertEquals(100L, item.getUnitPrice()); + assertEquals(100L, item.getAmount()); + assertEquals(0, item.getFreeQuantity()); + assertEquals(1, item.getBillingCycles()); + } + } + + @Nested + @DisplayName("Empty/absent collections") + class EmptyCollections { + + @Test void emptyArraysAreEmptyLists() { + assertNotNull(subscription.getItemTiers()); + assertTrue(subscription.getItemTiers().isEmpty()); + + assertNotNull(subscription.getChargedItems()); + assertTrue(subscription.getChargedItems().isEmpty()); + + assertNotNull(subscription.getCoupons()); + assertTrue(subscription.getCoupons().isEmpty()); + + assertNotNull(subscription.getDiscounts()); + assertTrue(subscription.getDiscounts().isEmpty()); + + assertNotNull(subscription.getAddons()); + assertTrue(subscription.getAddons().isEmpty()); + } + } + + @Nested + @DisplayName("Custom fields") + class CustomFieldsTests { + + @Test void parsesCustomFields() { + assertNotNull(subscription.getCustomFields()); + assertEquals(2, subscription.getCustomFields().size()); + assertEquals("enterprise", subscription.getCustomField("cf_license_tier")); + assertEquals("Jane Smith", subscription.getCustomField("cf_account_manager")); + } + } +} diff --git a/src/test/java/com/chargebee/v4/internal/TransactionParserTest.java b/src/test/java/com/chargebee/v4/internal/TransactionParserTest.java new file mode 100644 index 00000000..7c8ed4dc --- /dev/null +++ b/src/test/java/com/chargebee/v4/internal/TransactionParserTest.java @@ -0,0 +1,109 @@ +package com.chargebee.v4.internal; + +import com.chargebee.v4.models.transaction.Transaction; +import org.junit.jupiter.api.*; + +import java.io.IOException; +import java.io.InputStream; +import java.math.BigDecimal; +import java.nio.charset.StandardCharsets; +import java.sql.Timestamp; + +import static org.junit.jupiter.api.Assertions.*; + +@DisplayName("Transaction JSON parsing") +class TransactionParserTest { + + private static String transactionJson; + private static Transaction transaction; + + @BeforeAll + static void loadFixture() throws IOException { + try (InputStream is = TransactionParserTest.class.getResourceAsStream("/fixtures/transaction.json")) { + assertNotNull(is, "fixtures/transaction.json not found on classpath"); + transactionJson = new String(is.readAllBytes(), StandardCharsets.UTF_8); + } + transaction = Transaction.fromJson(transactionJson); + } + + @Nested + @DisplayName("Top-level scalar fields") + class TopLevelFields { + + @Test void parsesStringFields() { + assertEquals("txn___test__KyVnHhSBWltv42pB", transaction.getId()); + assertEquals("__test__KyVnHhSBWltgF2p6", transaction.getCustomerId()); + assertEquals("gw___test__KyVnGlSBWltbL2AB", transaction.getGatewayAccountId()); + assertEquals("pm___test__KyVnHhSBWltu42p7", transaction.getPaymentSourceId()); + assertEquals("USD", transaction.getCurrencyCode()); + assertEquals("ch_1HUyC0Jv9j0DyntJiR6W37yv", transaction.getIdAtGateway()); + assertEquals("Payment complete.", transaction.getFraudReason()); + assertEquals("************1111", transaction.getMaskedCardNumber()); + } + + @Test void parsesBooleanFields() { + assertEquals(false, transaction.getDeleted()); + } + + @Test void parsesLongFields() { + assertEquals(1000L, transaction.getAmount()); + assertEquals(1000L, transaction.getAmountCapturable()); + assertEquals(1517505917000L, transaction.getResourceVersion()); + } + + @Test void parsesBigDecimalFields() { + assertEquals(0, new BigDecimal("1").compareTo(transaction.getExchangeRate())); + } + + @Test void parsesEnumFields() { + assertEquals(Transaction.Status.SUCCESS, transaction.getStatus()); + assertEquals(Transaction.Type.AUTHORIZATION, transaction.getType()); + assertEquals(Transaction.PaymentMethod.CARD, transaction.getPaymentMethod()); + assertEquals(Transaction.Gateway.STRIPE, transaction.getGateway()); + assertEquals(Transaction.AuthorizationReason.BLOCKING_FUNDS, transaction.getAuthorizationReason()); + assertEquals(Transaction.FraudFlag._UNKNOWN, transaction.getFraudFlag()); + assertEquals(Transaction.InitiatorType._UNKNOWN, transaction.getInitiatorType()); + } + + @Test void parsesTimestampFields() { + assertEquals(new Timestamp(1600968316L * 1000), transaction.getDate()); + assertEquals(new Timestamp(1517505917L * 1000), transaction.getUpdatedAt()); + } + + @Test void absentFieldsAreNull() { + assertNull(transaction.getSubscriptionId()); + assertNull(transaction.getReferenceNumber()); + assertNull(transaction.getSettledAt()); + assertNull(transaction.getThreeDSecure()); + assertNull(transaction.getErrorCode()); + assertNull(transaction.getErrorText()); + assertNull(transaction.getVoidedAt()); + assertNull(transaction.getAmountUnused()); + assertNull(transaction.getReferenceTransactionId()); + assertNull(transaction.getRefundedTxnId()); + assertNull(transaction.getReferenceAuthorizationId()); + assertNull(transaction.getReversalTransactionId()); + assertNull(transaction.getBusinessEntityId()); + assertNull(transaction.getErrorDetail()); + } + } + + @Nested + @DisplayName("Empty/absent collections") + class EmptyCollections { + + @Test void emptyArraysAreEmptyLists() { + assertNotNull(transaction.getLinkedInvoices()); + assertTrue(transaction.getLinkedInvoices().isEmpty()); + + assertNotNull(transaction.getLinkedCreditNotes()); + assertTrue(transaction.getLinkedCreditNotes().isEmpty()); + + assertNotNull(transaction.getLinkedRefunds()); + assertTrue(transaction.getLinkedRefunds().isEmpty()); + + assertNotNull(transaction.getLinkedPayments()); + assertTrue(transaction.getLinkedPayments().isEmpty()); + } + } +} diff --git a/src/test/resources/fixtures/customer.json b/src/test/resources/fixtures/customer.json new file mode 100644 index 00000000..d035c14e --- /dev/null +++ b/src/test/resources/fixtures/customer.json @@ -0,0 +1,35 @@ +{ + "allow_direct_debit": false, + "auto_collection": "on", + "billing_address": { + "city": "Walnut", + "country": "US", + "first_name": "John", + "last_name": "Mike", + "line1": "PO Box 9999", + "object": "billing_address", + "state": "California", + "state_code": "CA", + "validation_status": "not_validated", + "zip": "91789" + }, + "card_status": "no_card", + "created_at": 1517505731, + "deleted": false, + "email": "john@test.com", + "excess_payments": 0, + "first_name": "John", + "id": "__test__KyVnHhSBWl7eY2bl", + "last_name": "Doe", + "locale": "fr-CA", + "net_term_days": 0, + "object": "customer", + "pii_cleared": "active", + "preferred_currency_code": "USD", + "promotional_credits": 0, + "refundable_credits": 0, + "resource_version": 1517505731000, + "taxability": "taxable", + "unbilled_charges": 0, + "updated_at": 1517505731 +} \ No newline at end of file diff --git a/src/test/resources/fixtures/customer_list.json b/src/test/resources/fixtures/customer_list.json new file mode 100644 index 00000000..435b11fd --- /dev/null +++ b/src/test/resources/fixtures/customer_list.json @@ -0,0 +1,103 @@ +{ + "list": [ + { + "customer": { + "id": "cust_AzZhUGSP1", + "first_name": "John", + "last_name": "Doe", + "email": "john@example.com", + "auto_collection": "on", + "net_term_days": 0, + "allow_direct_debit": false, + "created_at": 1605530769, + "updated_at": 1605530800, + "resource_version": 1605530800000, + "deleted": false, + "pii_cleared": "active", + "taxability": "taxable", + "preferred_currency_code": "USD", + "promotional_credits": 0, + "refundable_credits": 0, + "unbilled_charges": 0, + "excess_payments": 0, + "object": "customer", + "billing_address": { + "first_name": "John", + "last_name": "Doe", + "line1": "123 Main St", + "city": "San Francisco", + "state_code": "CA", + "state": "California", + "country": "US", + "zip": "94105", + "validation_status": "not_validated", + "object": "billing_address" + } + } + }, + { + "customer": { + "id": "cust_AzZhUGSP2", + "first_name": "Jane", + "last_name": "Smith", + "email": "jane@example.com", + "auto_collection": "off", + "net_term_days": 30, + "allow_direct_debit": true, + "created_at": 1605530900, + "updated_at": 1605530950, + "resource_version": 1605530950000, + "deleted": false, + "pii_cleared": "active", + "taxability": "taxable", + "preferred_currency_code": "EUR", + "promotional_credits": 500, + "refundable_credits": 100, + "unbilled_charges": 200, + "excess_payments": 0, + "object": "customer" + } + }, + { + "customer": { + "id": "cust_AzZhUGSP3", + "first_name": "Bob", + "last_name": "Wilson", + "email": "bob@example.com", + "auto_collection": "on", + "net_term_days": 0, + "allow_direct_debit": false, + "created_at": 1605531000, + "updated_at": 1605531050, + "resource_version": 1605531050000, + "deleted": false, + "pii_cleared": "active", + "taxability": "exempt", + "preferred_currency_code": "USD", + "promotional_credits": 0, + "refundable_credits": 0, + "unbilled_charges": 0, + "excess_payments": 0, + "object": "customer" + }, + "card": { + "status": "valid", + "gateway": "stripe", + "gateway_account_id": "gw_123", + "first_name": "Bob", + "last_name": "Wilson", + "iin": "411111", + "last4": "1111", + "card_type": "visa", + "funding_type": "credit", + "expiry_month": 12, + "expiry_year": 2028, + "masked_number": "************1111", + "object": "card", + "customer_id": "cust_AzZhUGSP3", + "payment_source_id": "pm_AzZhUGSP3" + } + } + ], + "next_offset": "[\"1605531050000\",\"3\"]" +} diff --git a/src/test/resources/fixtures/events.json b/src/test/resources/fixtures/events.json new file mode 100644 index 00000000..fc0b42fc --- /dev/null +++ b/src/test/resources/fixtures/events.json @@ -0,0 +1,200 @@ +{ + "event": { + "id": "ev_16BPgETyVrQbiGhA", + "occurred_at": 1702645601, + "source": "admin_console", + "user": "sarah@sarah.com", + "object": "event", + "api_version": "v2", + "content": { + "subscription": { + "id": "16BPgETyVrQVHGh1", + "billing_period": 1, + "billing_period_unit": "month", + "customer_id": "sarah", + "status": "active", + "current_term_start": 1702578600, + "current_term_end": 1705256999, + "next_billing_at": 1705257000, + "created_at": 1702645601, + "started_at": 1702578600, + "activated_at": 1702578600, + "created_from_ip": "10.0.0.1", + "updated_at": 1702645601, + "has_scheduled_changes": false, + "channel": "web", + "resource_version": 1702645601793, + "deleted": false, + "object": "subscription", + "currency_code": "INR", + "subscription_items": [ + { + "item_price_id": "cross-train-advanced-INR-1_MONTH", + "item_type": "plan", + "quantity": 1, + "quantity_in_decimal": "1.0000", + "unit_price": 11667, + "unit_price_in_decimal": "116.66667", + "amount": 11667, + "amount_in_decimal": "116.66667", + "free_quantity": 0, + "free_quantity_in_decimal": "0.0000", + "object": "subscription_item" + } + ], + "due_invoices_count": 0, + "mrr": 0, + "has_scheduled_advance_invoices": false, + "override_relationship": false, + "create_pending_invoices": false, + "auto_close_invoices": true, + "business_entity_id": "16CQtCTrgrYwi9n2E" + }, + "customer": { + "id": "sarah", + "auto_collection": "on", + "net_term_days": 0, + "allow_direct_debit": false, + "created_at": 1700038561, + "created_from_ip": "10.0.0.2", + "taxability": "taxable", + "updated_at": 1702645580, + "pii_cleared": "active", + "channel": "web", + "resource_version": 1702645580741, + "deleted": false, + "object": "customer", + "card_status": "valid", + "promotional_credits": 0, + "refundable_credits": 0, + "excess_payments": 0, + "unbilled_charges": 0, + "preferred_currency_code": "INR", + "mrr": 0, + "primary_payment_source_id": "pm_169vujTyVrL5fFDl", + "payment_method": { + "object": "payment_method", + "type": "card", + "reference_id": "tok_169vujTyVrL5LFDk", + "gateway": "chargebee", + "gateway_account_id": "gw_1mk51R4QrLmQtYMht", + "status": "valid" + }, + "business_entity_id": "16CQtCTrgrYwi9n2E", + "tax_providers_fields": {}, + "auto_close_invoices": true + }, + "card": { + "status": "valid", + "gateway": "chargebee", + "gateway_account_id": "gw_1mk51R4QrLmQtYMht", + "iin": "411111", + "last4": "1111", + "card_type": "visa", + "funding_type": "credit", + "expiry_month": 12, + "expiry_year": 2024, + "created_at": 1702645580, + "updated_at": 1702645580, + "ip_address": "10.0.0.1", + "resource_version": 1702645580740, + "object": "card", + "masked_number": "************1111", + "customer_id": "boom", + "payment_source_id": "pm_169vujTyVrL5fFDl" + }, + "invoice": { + "id": "203", + "customer_id": "boom", + "subscription_id": "16BPgETyVrQVHGh1", + "recurring": true, + "status": "paid", + "price_type": "tax_exclusive", + "date": 1702578600, + "due_date": 1702578600, + "net_term_days": 0, + "exchange_rate": 83.283543, + "total": 11667, + "amount_paid": 11667, + "amount_adjusted": 0, + "write_off_amount": 0, + "credits_applied": 0, + "amount_due": 0, + "paid_at": 1702645601, + "updated_at": 1702645601, + "resource_version": 1702645601783, + "deleted": false, + "object": "invoice", + "first_invoice": true, + "amount_to_collect": 0, + "round_off_amount": 0, + "new_sales_amount": 11667, + "has_advance_charges": false, + "currency_code": "INR", + "base_currency_code": "USD", + "generated_at": 1702578600, + "is_gifted": false, + "term_finalized": true, + "channel": "web", + "tax": 0, + "line_items": [ + { + "id": "li_16BPgETyVrQWBGh3", + "date_from": 1702578600, + "date_to": 1705256999, + "unit_amount": 11667, + "quantity": 1, + "amount": 11667, + "pricing_model": "per_unit", + "is_taxed": false, + "tax_amount": 0, + "unit_amount_in_decimal": "116.66667", + "quantity_in_decimal": "1.0000", + "amount_in_decimal": "116.66667", + "object": "line_item", + "subscription_id": "16BPgETyVrQVHGh1", + "customer_id": "boom", + "description": "cross-train-advanced-INR-1_MONTH", + "entity_type": "plan_item_price", + "entity_id": "cross-train-advanced-INR-1_MONTH", + "metered": false, + "tax_exempt_reason": "export", + "discount_amount": 0, + "item_level_discount_amount": 0 + } + ], + "sub_total": 11667, + "linked_payments": [ + { + "txn_id": "txn_16BPgETyVrQXVGh4", + "applied_amount": 11667, + "applied_at": 1702645601, + "txn_status": "success", + "txn_date": 1702645601, + "txn_amount": 11667 + } + ], + "applied_credits": {}, + "adjustment_credit_notes": {}, + "issued_credit_notes": {}, + "linked_orders": {}, + "dunning_attempts": {}, + "notes": [ + { + "note": "You can pay card." + } + ], + "business_entity_id": "16CQtCTrgrYwi9n2E" + } + }, + "event_type": "subscription_created", + "webhook_status": "not_configured", + "webhooks": [ + { + "id": "whv2_Azz5aITsMVdKtVWV", + "webhook_status": "not_applicable", + "object": "webhook" + } + ] + } +} \ No newline at end of file diff --git a/src/test/resources/fixtures/invoice.json b/src/test/resources/fixtures/invoice.json new file mode 100644 index 00000000..7823746d --- /dev/null +++ b/src/test/resources/fixtures/invoice.json @@ -0,0 +1,115 @@ +{ + "adjustment_credit_notes": {}, + "amount_adjusted": 0, + "amount_due": 0, + "amount_paid": 2000, + "amount_to_collect": 0, + "applied_credits": {}, + "base_currency_code": "USD", + "billing_address": { + "first_name": "John", + "last_name": "Mathew", + "object": "billing_address", + "validation_status": "not_validated" + }, + "credits_applied": 0, + "currency_code": "USD", + "customer_id": "__test__KyVkkWS1xLskm8", + "date": 1517463749, + "deleted": false, + "due_date": 1517463749, + "dunning_attempts": {}, + "exchange_rate": 1, + "first_invoice": true, + "has_advance_charges": false, + "id": "__demo_inv__1", + "is_gifted": false, + "issued_credit_notes": {}, + "line_items": [ + { + "amount": 2000, + "customer_id": "__test__KyVkkWS1xLskm8", + "date_from": 1517463749, + "date_to": 1517463749, + "description": "SSL Charge USD Monthly", + "discount_amount": 0, + "entity_id": "ssl-charge-USD", + "entity_type": "charge_item_price", + "id": "li___test__KyVkkWS1xLt9LF", + "is_taxed": false, + "item_level_discount_amount": 0, + "object": "line_item", + "pricing_model": "flat_fee", + "quantity": 1, + "tax_amount": 0, + "tax_exempt_reason": "tax_not_configured", + "unit_amount": 2000 + }, + { + "amount": 2000, + "customer_id": "__test__KyVkkWS1xLskm8", + "date_from": 1517463749, + "date_to": 1517463749, + "description": "SSL Charge USD Monthly", + "discount_amount": 0, + "entity_id": "ssl-charge-USD", + "entity_type": "charge_item_price", + "id": "li___test__KyVkkWS1xLt9LF", + "is_taxed": false, + "item_level_discount_amount": 0, + "object": "line_item", + "pricing_model": "flat_fee", + "quantity": 1, + "tax_amount": 0, + "tax_exempt_reason": "tax_not_configured", + "unit_amount": 2000 + } + ], + "linked_orders": {}, + "linked_payments": [ + { + "applied_amount": 2000, + "applied_at": 1517463750, + "txn_amount": 2000, + "txn_date": 1517463750, + "txn_id": "txn___test__KyVkkWS1xLtFiG", + "txn_status": "success" + }, + { + "applied_amount": 0, + "applied_at": 1517463750, + "txn_amount": 2000, + "txn_date": 1517463750, + "txn_id": "txn___test__KyVkkWS1xLtFiG", + "txn_status": "success" + } + ], + "net_term_days": 0, + "new_sales_amount": 2000, + "object": "invoice", + "paid_at": 1517463750, + "price_type": "tax_exclusive", + "recurring": false, + "resource_version": 1517463750000, + "round_off_amount": 0, + "shipping_address": { + "city": "Walnut", + "country": "US", + "first_name": "John", + "last_name": "Mathew", + "object": "shipping_address", + "state": "California", + "state_code": "CA", + "validation_status": "not_validated", + "zip": "91789" + }, + "status": "paid", + "sub_total": 2000, + "tax": 0, + "term_finalized": true, + "total": 2000, + "updated_at": 1517463750, + "write_off_amount": 0, + "cf_department": "engineering", + "cf_cost_center": "CC-1042" +} \ No newline at end of file diff --git a/src/test/resources/fixtures/itemPrices.json b/src/test/resources/fixtures/itemPrices.json new file mode 100644 index 00000000..b227bbeb --- /dev/null +++ b/src/test/resources/fixtures/itemPrices.json @@ -0,0 +1,21 @@ +{ + "created_at": 1594106928, + "currency_code": "USD", + "external_name": "silver USD", + "free_quantity": 0, + "id": "silver-USD-monthly", + "is_taxable": true, + "item_id": "silver", + "item_type": "plan", + "name": "silver USD monthly", + "object": "item_price", + "period": 1, + "period_unit": "month", + "price": 1000, + "pricing_model": "per_unit", + "resource_version": 1594106928574, + "status": "active", + "updated_at": 1594106928, + "cf_product_line": "saas", + "cf_tier_level": "silver" +} \ No newline at end of file diff --git a/src/test/resources/fixtures/subscription.json b/src/test/resources/fixtures/subscription.json new file mode 100644 index 00000000..7269a666 --- /dev/null +++ b/src/test/resources/fixtures/subscription.json @@ -0,0 +1,48 @@ +{ + "activated_at": 1612890938, + "billing_period": 1, + "billing_period_unit": "month", + "created_at": 1612890938, + "currency_code": "USD", + "current_term_end": 1615310138, + "current_term_start": 1612890938, + "customer_id": "__test__8asukSOXe0QYSR", + "deleted": false, + "due_invoices_count": 1, + "due_since": 1612890938, + "has_scheduled_changes": false, + "id": "__test__8asukSOXe0W3SU", + "mrr": 0, + "next_billing_at": 1615310138, + "object": "subscription", + "remaining_billing_cycles": 1, + "resource_version": 1612890938000, + "started_at": 1612890938, + "status": "active", + "subscription_items": [ + { + "amount": 1000, + "billing_cycles": 1, + "free_quantity": 0, + "item_price_id": "basic-USD", + "item_type": "plan", + "object": "subscription_item", + "quantity": 1, + "unit_price": 1000 + }, + { + "amount": 100, + "billing_cycles": 1, + "free_quantity": 0, + "item_price_id": "addon-USD", + "item_type": "addon", + "object": "subscription_item", + "quantity": 1, + "unit_price": 100 + } + ], + "total_dues": 1100, + "updated_at": 1612890938, + "cf_license_tier": "enterprise", + "cf_account_manager": "Jane Smith" +} \ No newline at end of file diff --git a/src/test/resources/fixtures/transaction.json b/src/test/resources/fixtures/transaction.json new file mode 100644 index 00000000..166a07ff --- /dev/null +++ b/src/test/resources/fixtures/transaction.json @@ -0,0 +1,24 @@ +{ + "amount": 1000, + "amount_capturable": 1000, + "authorization_reason": "blocking_funds", + "currency_code": "USD", + "customer_id": "__test__KyVnHhSBWltgF2p6", + "date": 1600968316, + "deleted": false, + "exchange_rate": 1, + "fraud_reason": "Payment complete.", + "gateway": "stripe", + "gateway_account_id": "gw___test__KyVnGlSBWltbL2AB", + "id": "txn___test__KyVnHhSBWltv42pB", + "id_at_gateway": "ch_1HUyC0Jv9j0DyntJiR6W37yv", + "linked_payments": {}, + "masked_card_number": "************1111", + "object": "transaction", + "payment_method": "card", + "payment_source_id": "pm___test__KyVnHhSBWltu42p7", + "resource_version": 1517505917000, + "status": "success", + "type": "authorization", + "updated_at": 1517505917 +} \ No newline at end of file From 013c0001399305b9ba901066fee12d54d393c574 Mon Sep 17 00:00:00 2001 From: cb-karthikp Date: Tue, 24 Feb 2026 13:33:27 +0530 Subject: [PATCH 3/6] add gson dependency and handle jsonUtil --- README.md | 36 + build.gradle.kts | 1 + .../chargebee/v4/exceptions/APIException.java | 9 +- .../com/chargebee/v4/internal/JsonUtil.java | 987 ++++------- .../responses/MoveItemPriceResponse.java | 8 +- .../v4/services/TimeMachineService.java | 5 +- .../v4/transport/HttpStatusHandler.java | 29 +- .../v4/internal/EventParserTest.java | 8 +- .../chargebee/v4/internal/JsonUtilTest.java | 1490 +++++------------ 9 files changed, 804 insertions(+), 1769 deletions(-) diff --git a/README.md b/README.md index 873383db..eb00de92 100644 --- a/README.md +++ b/README.md @@ -64,6 +64,42 @@ dependencies { ``` +### Dependencies + +The Chargebee Java SDK uses [Gson](https://github.com/google/gson) `2.13.2` for JSON processing. Gson is declared as a regular dependency of the SDK and is therefore included transitively when the SDK is added to a project. + +#### Gson version conflicts + +Projects that already depend on a different version of Gson may encounter version conflicts. The build tool resolves a single version based on its dependency resolution strategy, which can lead to mismatches. + +**Gradle** selects the highest version by default. If the project uses an older Gson version, Gradle will resolve to the highest version (`2.13.2`) by default. To pin a specific version: + +```kotlin +configurations.all { + resolutionStrategy { + force("com.google.code.gson:gson:2.13.2") + } +} +``` + +**Maven** uses the nearest-wins strategy, meaning a direct dependency declared in the project takes precedence over the SDK's transitive dependency. If an older version is declared directly, it will override the SDK's version. To align versions, either upgrade the direct dependency or use ``: + +```xml + + + + com.google.code.gson + gson + 2.13.2 + + + +``` + +**Minimum compatible Gson version**: `2.8.6`. The SDK relies on `JsonParser.parseString()`, which was introduced in Gson 2.8.6. Versions older than 2.8.6 will cause a `NoSuchMethodError` at runtime. + +**Recommended**: Gson `2.10.1` or later is recommended for best compatibility. Projects unable to upgrade should verify that the resolved Gson version is at least `2.8.6`. + ### Install JAR files *** diff --git a/build.gradle.kts b/build.gradle.kts index 2366bb74..822fe15d 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -42,6 +42,7 @@ repositories { } dependencies { + implementation("com.google.code.gson:gson:2.13.2") testImplementation("org.junit.jupiter:junit-jupiter:5.13.0") testRuntimeOnly("org.junit.platform:junit-platform-launcher") testImplementation("org.mockito:mockito-core:4.11.0") diff --git a/src/main/java/com/chargebee/v4/exceptions/APIException.java b/src/main/java/com/chargebee/v4/exceptions/APIException.java index 7793ef97..e2a924ae 100644 --- a/src/main/java/com/chargebee/v4/exceptions/APIException.java +++ b/src/main/java/com/chargebee/v4/exceptions/APIException.java @@ -9,6 +9,8 @@ import com.chargebee.v4.internal.JsonUtil; import com.chargebee.v4.transport.Request; import com.chargebee.v4.transport.Response; +import com.google.gson.JsonArray; +import com.google.gson.JsonObject; import java.util.ArrayList; import java.util.List; @@ -229,11 +231,12 @@ public String getJsonResponse() { private List extractParams(String jsonResponse) { List paramsList = new ArrayList<>(); if (jsonResponse != null) { - String param = JsonUtil.getString(jsonResponse, "param"); + JsonObject obj = JsonUtil.parse(jsonResponse); + String param = JsonUtil.getString(obj, "param"); if (param != null) { paramsList.add(param); } else { - String paramArray = JsonUtil.getArray(jsonResponse, "param"); + JsonArray paramArray = JsonUtil.getJsonArray(obj, "param"); if (paramArray != null) { paramsList.addAll(JsonUtil.parseArrayOfString(paramArray)); } @@ -245,7 +248,7 @@ private List extractParams(String jsonResponse) { /** Extract error_cause_id from error response. */ private String extractErrorCauseId(String jsonResponse) { if (jsonResponse != null) { - return JsonUtil.getString(jsonResponse, "error_cause_id"); + return JsonUtil.getString(JsonUtil.parse(jsonResponse), "error_cause_id"); } return null; } diff --git a/src/main/java/com/chargebee/v4/internal/JsonUtil.java b/src/main/java/com/chargebee/v4/internal/JsonUtil.java index 45db5ada..c2ba6411 100644 --- a/src/main/java/com/chargebee/v4/internal/JsonUtil.java +++ b/src/main/java/com/chargebee/v4/internal/JsonUtil.java @@ -1,779 +1,376 @@ package com.chargebee.v4.internal; +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonNull; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; +import com.google.gson.JsonPrimitive; + +import java.math.BigDecimal; import java.sql.Timestamp; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; -import java.util.regex.Matcher; -import java.util.regex.Pattern; +import java.util.Map; +import java.util.Set; +import java.util.function.Function; -/** - * Simple JSON parsing utility for basic response parsing. - * Avoids heavy dependencies while providing essential JSON functionality. - */ +/** Gson-backed JSON parsing utility. */ public class JsonUtil { - - /** - * Extract string value from JSON for a given key. - */ - public static String getString(String json, String key) { - if (json == null || key == null) { - return null; + + private JsonUtil() {} + + // --- Parse entry points --- + + /** Parses a JSON string into a JsonObject; returns empty JsonObject on failure. */ + public static JsonObject parse(String json) { + if (json == null || json.trim().isEmpty()) { + return new JsonObject(); } - Pattern pattern = Pattern.compile("\"" + Pattern.quote(key) + "\"\\s*:\\s*\"([^\"\\\\]*(\\\\.[^\"\\\\]*)*)\""); - Matcher matcher = pattern.matcher(json); - if (matcher.find()) { - return unescapeJsonString(matcher.group(1)); + try { + return JsonParser.parseString(json).getAsJsonObject(); + } catch (Exception e) { + return new JsonObject(); } - return null; } - - /** - * Extract long value from JSON for a given key. - */ - public static Long getLong(String json, String key) { - if (json == null || key == null) { - return null; + + /** Parses a JSON string into a JsonArray; returns empty JsonArray on failure. */ + public static JsonArray parseToArray(String arrayJson) { + if (arrayJson == null || arrayJson.trim().isEmpty()) { + return new JsonArray(); } - Pattern pattern = Pattern.compile("\"" + Pattern.quote(key) + "\"\\s*:\\s*(-?\\d+)"); - Matcher matcher = pattern.matcher(json); - if (matcher.find()) { - return Long.parseLong(matcher.group(1)); + try { + return JsonParser.parseString(arrayJson).getAsJsonArray(); + } catch (Exception e) { + return new JsonArray(); } - return null; } - - /** - * Extract integer value from JSON for a given key. - */ - public static Integer getInteger(String json, String key) { - if (json == null || key == null) { - return null; - } - Pattern pattern = Pattern.compile("\"" + Pattern.quote(key) + "\"\\s*:\\s*(-?\\d+)"); - Matcher matcher = pattern.matcher(json); - if (matcher.find()) { - return Integer.parseInt(matcher.group(1)); - } - return null; + + // --- JsonObject-based extraction --- + + /** Returns the String value for the given key, or null. */ + public static String getString(JsonObject obj, String key) { + if (obj == null || key == null) return null; + JsonElement elem = obj.get(key); + if (elem == null || elem.isJsonNull()) return null; + try { return elem.getAsString(); } catch (Exception e) { return null; } } - - /** - * Extract boolean value from JSON for a given key. - */ - public static Boolean getBoolean(String json, String key) { - if (json == null || key == null) { - return null; - } - Pattern pattern = Pattern.compile("\"" + Pattern.quote(key) + "\"\\s*:\\s*(true|false)"); - Matcher matcher = pattern.matcher(json); - if (matcher.find()) { - return Boolean.parseBoolean(matcher.group(1)); - } - return null; + + /** Returns the Long value for the given key, or null. */ + public static Long getLong(JsonObject obj, String key) { + if (obj == null || key == null) return null; + JsonElement elem = obj.get(key); + if (elem == null || elem.isJsonNull()) return null; + try { return elem.getAsLong(); } catch (Exception e) { return null; } } - - /** - * Extract double value from JSON for a given key. - */ - public static Double getDouble(String json, String key) { - if (json == null || key == null) { - return null; - } - Pattern pattern = Pattern.compile("\"" + Pattern.quote(key) + "\"\\s*:\\s*(-?\\d+(?:\\.\\d+)?)"); - Matcher matcher = pattern.matcher(json); - if (matcher.find()) { - return Double.parseDouble(matcher.group(1)); - } - return null; + + /** Returns the Integer value for the given key, or null. */ + public static Integer getInteger(JsonObject obj, String key) { + if (obj == null || key == null) return null; + JsonElement elem = obj.get(key); + if (elem == null || elem.isJsonNull()) return null; + try { return elem.getAsInt(); } catch (Exception e) { return null; } } - - /** - * Extract number value from JSON for a given key. - * Returns Double for numeric values. - */ - public static Number getNumber(String json, String key) { - if (json == null || key == null) { - return null; - } - return getDouble(json, key); + + /** Returns the Boolean value for the given key, or null. */ + public static Boolean getBoolean(JsonObject obj, String key) { + if (obj == null || key == null) return null; + JsonElement elem = obj.get(key); + if (elem == null || elem.isJsonNull()) return null; + try { return elem.getAsBoolean(); } catch (Exception e) { return null; } } - - /** - * Extract BigDecimal value from JSON for a given key. - */ - public static java.math.BigDecimal getBigDecimal(String json, String key) { - if (json == null || key == null) { - return null; - } - Pattern pattern = Pattern.compile("\"" + Pattern.quote(key) + "\"\\s*:\\s*(-?\\d+(?:\\.\\d+)?)"); - Matcher matcher = pattern.matcher(json); - if (matcher.find()) { - return new java.math.BigDecimal(matcher.group(1)); - } - return null; + + /** Returns the Double value for the given key, or null. */ + public static Double getDouble(JsonObject obj, String key) { + if (obj == null || key == null) return null; + JsonElement elem = obj.get(key); + if (elem == null || elem.isJsonNull()) return null; + try { return elem.getAsDouble(); } catch (Exception e) { return null; } } - /** - * Extract nested object as JSON string for a given key. - */ - public static String getObject(String json, String key) { - if (json == null || key == null) { - return null; - } - // Find the key position - String keyPattern = "\"" + Pattern.quote(key) + "\"\\s*:"; - Pattern pattern = Pattern.compile(keyPattern); - Matcher matcher = pattern.matcher(json); - if (!matcher.find()) { - return null; - } - - // Find the start of the object value (skip whitespace after colon) - int start = matcher.end(); - while (start < json.length() && Character.isWhitespace(json.charAt(start))) { - start++; - } - - if (start >= json.length() || json.charAt(start) != '{') { - return null; - } - - // Extract the object by tracking brace depth - int depth = 0; - boolean inString = false; - boolean escaped = false; - int objectStart = start; - - for (int i = start; i < json.length(); i++) { - char c = json.charAt(i); - - if (escaped) { - escaped = false; - continue; - } - - if (c == '\\' && inString) { - escaped = true; - continue; - } - - if (c == '"' && !escaped) { - inString = !inString; - continue; - } - - if (!inString) { - if (c == '{') { - depth++; - } else if (c == '}') { - depth--; - if (depth == 0) { - return json.substring(objectStart, i + 1); - } - } - } - } - - return null; + /** Returns the Number value for the given key, or null. */ + public static Number getNumber(JsonObject obj, String key) { + return getDouble(obj, key); } - - /** - * Extract array as JSON string for a given key. - * Handles nested arrays and objects by tracking bracket depth. - */ - public static String getArray(String json, String key) { - if (json == null || key == null) { - return null; - } - - // Find the key position - String keyPattern = "\"" + Pattern.quote(key) + "\"\\s*:\\s*\\["; - Pattern p = Pattern.compile(keyPattern); - Matcher matcher = p.matcher(json); - if (!matcher.find()) { - return null; + + /** Returns the BigDecimal value for the given key, or null. */ + public static BigDecimal getBigDecimal(JsonObject obj, String key) { + if (obj == null || key == null) return null; + JsonElement elem = obj.get(key); + if (elem == null || elem.isJsonNull()) return null; + try { return elem.getAsBigDecimal(); } catch (Exception e) { return null; } + } + + /** Converts an epoch-seconds Long to a Timestamp, or null. */ + public static Timestamp getTimestamp(JsonObject obj, String key) { + Long epochSeconds = getLong(obj, key); + return epochSeconds != null ? new Timestamp(epochSeconds * 1000) : null; + } + + /** Returns a nested JsonObject for the given key, or null. */ + public static JsonObject getJsonObject(JsonObject obj, String key) { + if (obj == null || key == null) return null; + JsonElement elem = obj.get(key); + if (elem == null || elem.isJsonNull() || !elem.isJsonObject()) return null; + return elem.getAsJsonObject(); + } + + /** Returns a nested JsonArray for the given key, or null. */ + public static JsonArray getJsonArray(JsonObject obj, String key) { + if (obj == null || key == null) return null; + JsonElement elem = obj.get(key); + if (elem == null || elem.isJsonNull() || !elem.isJsonArray()) return null; + return elem.getAsJsonArray(); + } + + /** Returns a nested object as a JSON string for the given key, or null. */ + public static String getObject(JsonObject obj, String key) { + if (obj == null || key == null) return null; + JsonElement elem = obj.get(key); + if (elem == null || elem.isJsonNull() || !elem.isJsonObject()) return null; + return elem.toString(); + } + + /** Returns a nested array as a JSON string for the given key, or null. */ + public static String getArray(JsonObject obj, String key) { + if (obj == null || key == null) return null; + JsonElement elem = obj.get(key); + if (elem == null || elem.isJsonNull() || !elem.isJsonArray()) return null; + return elem.toString(); + } + + /** Returns true if the key exists and is not null. */ + public static boolean hasValue(JsonObject obj, String key) { + if (obj == null || key == null) return false; + JsonElement elem = obj.get(key); + return elem != null && !elem.isJsonNull(); + } + + // --- JsonObject to Map conversion --- + + /** Converts a JsonObject to a Map; primitives become Java types, nested structures become JSON strings. */ + public static Map parseJsonObjectToMap(JsonObject obj) { + Map map = new HashMap<>(); + if (obj == null) return map; + for (Map.Entry entry : obj.entrySet()) { + map.put(entry.getKey(), toJavaValue(entry.getValue())); } - - // Start from the opening bracket - int start = matcher.end() - 1; // Position of '[' - int depth = 0; - boolean inString = false; - boolean escaped = false; - - for (int i = start; i < json.length(); i++) { - char c = json.charAt(i); - - if (escaped) { - escaped = false; - continue; - } - - if (c == '\\' && inString) { - escaped = true; - continue; - } - - if (c == '"' && !escaped) { - inString = !inString; - continue; - } - - if (!inString) { - if (c == '[') { - depth++; - } else if (c == ']') { - depth--; - if (depth == 0) { - return json.substring(start, i + 1); - } - } + return map; + } + + // --- JsonArray-based extraction --- + + /** Maps each JsonObject element through the given function; e.g. {@code mapArray(arr, Model::fromJson)}. */ + public static List mapArray(JsonArray array, Function mapper) { + if (array == null) return new ArrayList<>(); + List result = new ArrayList<>(array.size()); + for (JsonElement elem : array) { + if (elem != null && elem.isJsonObject()) { + result.add(mapper.apply(elem.getAsJsonObject())); } } - return null; + return result; } - - /** - * Parse array of objects and extract each object as JSON string. - */ - public static List parseObjectArray(String arrayJson) { - List objects = new ArrayList<>(); - if (arrayJson == null || !arrayJson.trim().startsWith("[")) { - return objects; - } - - // Simple object extraction from array - int depth = 0; - int start = -1; - boolean inString = false; - boolean escaped = false; - - for (int i = 0; i < arrayJson.length(); i++) { - char c = arrayJson.charAt(i); - - if (escaped) { - escaped = false; - continue; - } - - if (c == '\\' && inString) { - escaped = true; - continue; - } - - if (c == '"' && !escaped) { - inString = !inString; - continue; - } - - if (!inString) { - if (c == '{') { - if (depth == 0) { - start = i; - } - depth++; - } else if (c == '}') { - depth--; - if (depth == 0 && start != -1) { - objects.add(arrayJson.substring(start, i + 1)); - start = -1; - } - } + + /** Converts each JsonArray element to its Java value, returning {@code List}. */ + public static List mapArrayToObjects(JsonArray array) { + if (array == null) return new ArrayList<>(); + List result = new ArrayList<>(array.size()); + for (JsonElement elem : array) { + if (elem != null && elem.isJsonObject()) { + result.add(parseJsonObjectToMap(elem.getAsJsonObject())); + } else { + result.add(toJavaValue(elem)); } } - - return objects; + return result; } - - /** - * Check if a key exists and has non-null value. - */ - public static boolean hasValue(String json, String key) { - if (json == null || key == null) { - return false; - } - // First check if the key exists with null value - Pattern nullPattern = Pattern.compile("\"" + Pattern.quote(key) + "\"\\s*:\\s*null\\b"); - if (nullPattern.matcher(json).find()) { - return false; + + /** Converts each JsonObject element to a {@code Map}; skips non-object elements. */ + public static List> mapArrayToMaps(JsonArray array) { + if (array == null) return new ArrayList<>(); + List> result = new ArrayList<>(array.size()); + for (JsonElement elem : array) { + if (elem != null && elem.isJsonObject()) { + result.add(parseJsonObjectToMap(elem.getAsJsonObject())); + } } - // Then check if the key exists at all - Pattern keyPattern = Pattern.compile("\"" + Pattern.quote(key) + "\"\\s*:"); - return keyPattern.matcher(json).find(); + return result; } - - /** - * Parse array of strings from JSON array string. - */ - public static List parseArrayOfString(String arrayJson) { + + /** Parses a JsonArray of strings into a List. */ + public static List parseArrayOfString(JsonArray array) { List result = new ArrayList<>(); - if (arrayJson == null || arrayJson.trim().equals("[]")) { - return result; - } - - // Extract string values from array - Pattern pattern = Pattern.compile("\"([^\"\\\\]*(\\\\.[^\"\\\\]*)*)\""); - Matcher matcher = pattern.matcher(arrayJson); - while (matcher.find()) { - result.add(unescapeJsonString(matcher.group(1))); + if (array == null) return result; + for (JsonElement elem : array) { + if (elem != null && !elem.isJsonNull()) { + result.add(elem.getAsString()); + } } return result; } - /** - * Parse array of integers from JSON array string. - */ - public static List parseArrayOfInteger(String arrayJson) { + /** Parses a JsonArray of integers into a List. */ + public static List parseArrayOfInteger(JsonArray array) { List result = new ArrayList<>(); - if (arrayJson == null || arrayJson.trim().equals("[]")) { - return result; - } - - // Extract integer values from array - Pattern pattern = Pattern.compile("(-?\\d+)(?![.\\d])"); - Matcher matcher = pattern.matcher(arrayJson); - while (matcher.find()) { - try { - result.add(Integer.parseInt(matcher.group(1))); - } catch (NumberFormatException e) { - // Skip invalid numbers + if (array == null) return result; + for (JsonElement elem : array) { + if (elem != null && !elem.isJsonNull()) { + try { result.add(elem.getAsInt()); } catch (Exception e) { /* skip */ } } } return result; } - /** - * Parse array of longs from JSON array string. - */ - public static List parseArrayOfLong(String arrayJson) { + /** Parses a JsonArray of longs into a List. */ + public static List parseArrayOfLong(JsonArray array) { List result = new ArrayList<>(); - if (arrayJson == null || arrayJson.trim().equals("[]")) { - return result; - } - - // Extract long values from array - Pattern pattern = Pattern.compile("(-?\\d+)(?![.\\d])"); - Matcher matcher = pattern.matcher(arrayJson); - while (matcher.find()) { - try { - result.add(Long.parseLong(matcher.group(1))); - } catch (NumberFormatException e) { - // Skip invalid numbers + if (array == null) return result; + for (JsonElement elem : array) { + if (elem != null && !elem.isJsonNull()) { + try { result.add(elem.getAsLong()); } catch (Exception e) { /* skip */ } } } return result; } - /** - * Parse array of booleans from JSON array string. - */ - public static List parseArrayOfBoolean(String arrayJson) { + /** Parses a JsonArray of booleans into a List. */ + public static List parseArrayOfBoolean(JsonArray array) { List result = new ArrayList<>(); - if (arrayJson == null || arrayJson.trim().equals("[]")) { - return result; - } - - // Extract boolean values from array - Pattern pattern = Pattern.compile("\\b(true|false)\\b"); - Matcher matcher = pattern.matcher(arrayJson); - while (matcher.find()) { - result.add(Boolean.parseBoolean(matcher.group(1))); + if (array == null) return result; + for (JsonElement elem : array) { + if (elem != null && !elem.isJsonNull()) { + try { result.add(elem.getAsBoolean()); } catch (Exception e) { /* skip */ } + } } return result; } - /** - * Parse array of doubles from JSON array string. - */ - public static List parseArrayOfDouble(String arrayJson) { + /** Parses a JsonArray of doubles into a List. */ + public static List parseArrayOfDouble(JsonArray array) { List result = new ArrayList<>(); - if (arrayJson == null || arrayJson.trim().equals("[]")) { - return result; - } - - // Extract double values from array - Pattern pattern = Pattern.compile("(-?\\d+(?:\\.\\d+)?)"); - Matcher matcher = pattern.matcher(arrayJson); - while (matcher.find()) { - try { - result.add(Double.parseDouble(matcher.group(1))); - } catch (NumberFormatException e) { - // Skip invalid numbers + if (array == null) return result; + for (JsonElement elem : array) { + if (elem != null && !elem.isJsonNull()) { + try { result.add(elem.getAsDouble()); } catch (Exception e) { /* skip */ } } } return result; } - /** - * Parse array of BigDecimal from JSON array string. - */ - public static List parseArrayOfBigDecimal(String arrayJson) { - List result = new ArrayList<>(); - if (arrayJson == null || arrayJson.trim().equals("[]")) { - return result; - } - - // Extract BigDecimal values from array - Pattern pattern = Pattern.compile("(-?\\d+(?:\\.\\d+)?)"); - Matcher matcher = pattern.matcher(arrayJson); - while (matcher.find()) { - try { - result.add(new java.math.BigDecimal(matcher.group(1))); - } catch (NumberFormatException e) { - // Skip invalid numbers + /** Parses a JsonArray of BigDecimals into a List. */ + public static List parseArrayOfBigDecimal(JsonArray array) { + List result = new ArrayList<>(); + if (array == null) return result; + for (JsonElement elem : array) { + if (elem != null && !elem.isJsonNull()) { + try { result.add(elem.getAsBigDecimal()); } catch (Exception e) { /* skip */ } } } return result; } - /** - * Parse timestamp from JSON (Unix epoch seconds). - */ - public static Timestamp getTimestamp(String json, String key) { - Long epochSeconds = getLong(json, key); - return epochSeconds != null ? new Timestamp(epochSeconds * 1000) : null; - } + // --- Custom / consent field extraction --- - /** - * Parse a JSON object into a Map<String, Object>. - * Values are kept as their raw types (String, Long, Double, Boolean, or nested JSON strings). - */ - public static java.util.Map parseJsonObjectToMap(String json) { - java.util.Map map = new java.util.HashMap<>(); - if (json == null || json.trim().isEmpty() || json.trim().equals("{}")) { - return map; - } - - // Remove outer braces and trim - String content = json.trim(); - if (content.startsWith("{")) { - content = content.substring(1); - } - if (content.endsWith("}")) { - content = content.substring(0, content.length() - 1); - } - content = content.trim(); - - if (content.isEmpty()) { - return map; - } - - // Parse key-value pairs - int i = 0; - while (i < content.length()) { - // Skip whitespace - while (i < content.length() && Character.isWhitespace(content.charAt(i))) { - i++; - } - if (i >= content.length()) break; - - // Parse key (must be quoted) - if (content.charAt(i) != '"') { - break; // Invalid JSON - } - i++; // Skip opening quote - - StringBuilder keyBuilder = new StringBuilder(); - boolean escaped = false; - while (i < content.length()) { - char c = content.charAt(i); - if (escaped) { - keyBuilder.append(c); - escaped = false; - } else if (c == '\\') { - escaped = true; - } else if (c == '"') { - i++; // Skip closing quote - break; + /** Extracts keys starting with "cf_" that are not in the known fields set. */ + public static Map extractCustomFields(JsonObject obj, Set knownFields) { + Map customFields = new HashMap<>(); + if (obj == null) return customFields; + for (Map.Entry entry : obj.entrySet()) { + String key = entry.getKey(); + if (key != null && key.startsWith("cf_") && !knownFields.contains(key)) { + JsonElement value = entry.getValue(); + if (value == null || value.isJsonNull()) { + customFields.put(key, null); + } else if (value.isJsonPrimitive()) { + customFields.put(key, value.getAsString()); } else { - keyBuilder.append(c); + customFields.put(key, value.toString()); } - i++; - } - String key = keyBuilder.toString(); - - // Skip whitespace and colon - while (i < content.length() && (Character.isWhitespace(content.charAt(i)) || content.charAt(i) == ':')) { - i++; - } - - // Parse value - Object value = null; - if (i < content.length()) { - char c = content.charAt(i); - - if (c == '"') { - // String value - i++; // Skip opening quote - StringBuilder valueBuilder = new StringBuilder(); - escaped = false; - while (i < content.length()) { - c = content.charAt(i); - if (escaped) { - valueBuilder.append(c); - escaped = false; - } else if (c == '\\') { - escaped = true; - } else if (c == '"') { - i++; // Skip closing quote - break; - } else { - valueBuilder.append(c); - } - i++; - } - value = unescapeJsonString(valueBuilder.toString()); - - } else if (c == '{') { - // Nested object - extract as JSON string - int depth = 0; - int start = i; - boolean inString = false; - escaped = false; - while (i < content.length()) { - c = content.charAt(i); - if (escaped) { - escaped = false; - } else if (c == '\\' && inString) { - escaped = true; - } else if (c == '"') { - inString = !inString; - } else if (!inString) { - if (c == '{') depth++; - else if (c == '}') { - depth--; - if (depth == 0) { - i++; - break; - } - } - } - i++; - } - value = content.substring(start, i); - - } else if (c == '[') { - // Array - extract as JSON string - int depth = 0; - int start = i; - boolean inString = false; - escaped = false; - while (i < content.length()) { - c = content.charAt(i); - if (escaped) { - escaped = false; - } else if (c == '\\' && inString) { - escaped = true; - } else if (c == '"') { - inString = !inString; - } else if (!inString) { - if (c == '[') depth++; - else if (c == ']') { - depth--; - if (depth == 0) { - i++; - break; - } - } - } - i++; - } - value = content.substring(start, i); - - } else if (c == 't' && content.substring(i).startsWith("true")) { - // Boolean true - value = Boolean.TRUE; - i += 4; - - } else if (c == 'f' && content.substring(i).startsWith("false")) { - // Boolean false - value = Boolean.FALSE; - i += 5; - - } else if (c == 'n' && content.substring(i).startsWith("null")) { - // null - value = null; - i += 4; - - } else if (c == '-' || Character.isDigit(c)) { - // Number - StringBuilder numBuilder = new StringBuilder(); - while (i < content.length()) { - c = content.charAt(i); - if (c == '-' || c == '+' || c == '.' || c == 'e' || c == 'E' || Character.isDigit(c)) { - numBuilder.append(c); - i++; - } else { - break; - } - } - String numStr = numBuilder.toString(); - try { - if (numStr.contains(".") || numStr.contains("e") || numStr.contains("E")) { - value = Double.parseDouble(numStr); - } else { - value = Long.parseLong(numStr); - } - } catch (NumberFormatException e) { - value = numStr; // Fallback to string - } - } - } - - map.put(key, value); - - // Skip comma and whitespace - while (i < content.length() && (Character.isWhitespace(content.charAt(i)) || content.charAt(i) == ',')) { - i++; } } - - return map; + return customFields; } - /** - * Unescape JSON string. - * Processes escape sequences correctly by handling \\\\ last to avoid - * incorrectly interpreting sequences like \\t as tab. - */ - private static String unescapeJsonString(String escaped) { - if (escaped == null) return null; - - // Use a placeholder for \\ to avoid interference with other escapes - // e.g., \\t should become \t (backslash + t), not a tab character - String placeholder = "\u0000BACKSLASH\u0000"; - - return escaped - .replace("\\\\", placeholder) // Temporarily replace \\ with placeholder - .replace("\\\"", "\"") - .replace("\\/", "/") - .replace("\\b", "\b") - .replace("\\f", "\f") - .replace("\\n", "\n") - .replace("\\r", "\r") - .replace("\\t", "\t") - .replace(placeholder, "\\"); // Replace placeholder with actual backslash - } - - /** - * Serialize a Map to a JSON string. - */ - public static String toJson(java.util.Map map) { - if (map == null || map.isEmpty()) { - return "{}"; - } - - StringBuilder sb = new StringBuilder(); - sb.append('{'); - - boolean first = true; - for (java.util.Map.Entry entry : map.entrySet()) { - if (!first) { - sb.append(','); + /** Extracts keys starting with "cs_" that are not in the known fields set. */ + public static Map extractConsentFields(JsonObject obj, Set knownFields) { + Map consentFields = new HashMap<>(); + if (obj == null) return consentFields; + for (Map.Entry entry : obj.entrySet()) { + String key = entry.getKey(); + if (key != null && key.startsWith("cs_") && !knownFields.contains(key)) { + consentFields.put(key, toJavaValue(entry.getValue())); } - first = false; - - sb.append('"').append(escapeJsonString(entry.getKey())).append('"'); - sb.append(':'); - appendJsonValue(sb, entry.getValue()); } - - sb.append('}'); - return sb.toString(); + return consentFields; } - /** - * Serialize a List to a JSON string. - */ - public static String toJson(java.util.List list) { - if (list == null || list.isEmpty()) { - return "[]"; - } - StringBuilder sb = new StringBuilder(); - appendJsonList(sb, list); - return sb.toString(); - } - - /** - * Append a JSON value (handles different types). - */ + // --- Serialization --- + + /** Serializes a Map to a JSON string. */ @SuppressWarnings("unchecked") - private static void appendJsonValue(StringBuilder sb, Object value) { - if (value == null) { - sb.append("null"); - } else if (value instanceof String) { - sb.append('"').append(escapeJsonString((String) value)).append('"'); - } else if (value instanceof Number) { - sb.append(value.toString()); - } else if (value instanceof Boolean) { - sb.append(value.toString()); - } else if (value instanceof java.util.Map) { - sb.append(toJson((java.util.Map) value)); - } else if (value instanceof java.util.List) { - appendJsonList(sb, (java.util.List) value); - } else { - // Fallback: convert to string - sb.append('"').append(escapeJsonString(value.toString())).append('"'); + public static String toJson(Map map) { + if (map == null || map.isEmpty()) return "{}"; + JsonObject obj = new JsonObject(); + for (Map.Entry entry : map.entrySet()) { + obj.add(entry.getKey(), toJsonElement(entry.getValue())); } + return obj.toString(); } - - /** - * Append a JSON array. - */ - private static void appendJsonList(StringBuilder sb, java.util.List list) { - sb.append('['); - boolean first = true; + + /** Serializes a List to a JSON string. */ + public static String toJson(List list) { + if (list == null || list.isEmpty()) return "[]"; + JsonArray array = new JsonArray(); for (Object item : list) { - if (!first) { - sb.append(','); + array.add(toJsonElement(item)); + } + return array.toString(); + } + + // --- Internal helpers --- + + private static Object toJavaValue(JsonElement value) { + if (value == null || value.isJsonNull()) return null; + if (value.isJsonPrimitive()) { + JsonPrimitive prim = value.getAsJsonPrimitive(); + if (prim.isString()) return prim.getAsString(); + if (prim.isBoolean()) return prim.getAsBoolean(); + if (prim.isNumber()) { + String numStr = prim.getAsString(); + if (numStr.contains(".") || numStr.contains("e") || numStr.contains("E")) { + return prim.getAsDouble(); + } + return prim.getAsLong(); } - first = false; - appendJsonValue(sb, item); } - sb.append(']'); + if (value.isJsonObject() || value.isJsonArray()) { + return value.toString(); + } + return null; } - - /** - * Escape special characters in JSON strings. - */ - private static String escapeJsonString(String str) { - if (str == null) { - return ""; + + @SuppressWarnings("unchecked") + private static JsonElement toJsonElement(Object value) { + if (value == null) return JsonNull.INSTANCE; + if (value instanceof String) return new JsonPrimitive((String) value); + if (value instanceof Number) return new JsonPrimitive((Number) value); + if (value instanceof Boolean) return new JsonPrimitive((Boolean) value); + if (value instanceof Map) { + JsonObject obj = new JsonObject(); + for (Map.Entry entry : ((Map) value).entrySet()) { + obj.add(entry.getKey(), toJsonElement(entry.getValue())); + } + return obj; } - - StringBuilder escaped = new StringBuilder(); - for (int i = 0; i < str.length(); i++) { - char ch = str.charAt(i); - switch (ch) { - case '"': - escaped.append("\\\""); - break; - case '\\': - escaped.append("\\\\"); - break; - case '\b': - escaped.append("\\b"); - break; - case '\f': - escaped.append("\\f"); - break; - case '\n': - escaped.append("\\n"); - break; - case '\r': - escaped.append("\\r"); - break; - case '\t': - escaped.append("\\t"); - break; - default: - // Control characters - if (ch < ' ') { - escaped.append(String.format("\\u%04x", (int) ch)); - } else { - escaped.append(ch); - } + if (value instanceof List) { + JsonArray array = new JsonArray(); + for (Object item : (List) value) { + array.add(toJsonElement(item)); } + return array; } - return escaped.toString(); + return new JsonPrimitive(value.toString()); } -} \ No newline at end of file +} diff --git a/src/main/java/com/chargebee/v4/models/itemPrice/responses/MoveItemPriceResponse.java b/src/main/java/com/chargebee/v4/models/itemPrice/responses/MoveItemPriceResponse.java index 45bf82fc..d1dc74b0 100644 --- a/src/main/java/com/chargebee/v4/models/itemPrice/responses/MoveItemPriceResponse.java +++ b/src/main/java/com/chargebee/v4/models/itemPrice/responses/MoveItemPriceResponse.java @@ -5,6 +5,7 @@ import com.chargebee.v4.models.BaseResponse; import com.chargebee.v4.internal.JsonUtil; import com.chargebee.v4.transport.Response; +import com.google.gson.JsonObject; /** * Immutable response object for MoveItemPrice operation. Contains the response data from the API. @@ -28,9 +29,10 @@ public static MoveItemPriceResponse fromJson(String json, Response httpResponse) try { Builder builder = builder(); - String __itemPriceJson = JsonUtil.getObject(json, "item_price"); - if (__itemPriceJson != null) { - builder.itemPrice(ItemPrice.fromJson(__itemPriceJson)); + JsonObject jsonObj = JsonUtil.parse(json); + JsonObject __itemPriceObj = JsonUtil.getJsonObject(jsonObj, "item_price"); + if (__itemPriceObj != null) { + builder.itemPrice(ItemPrice.fromJson(__itemPriceObj)); } builder.httpResponse(httpResponse); diff --git a/src/main/java/com/chargebee/v4/services/TimeMachineService.java b/src/main/java/com/chargebee/v4/services/TimeMachineService.java index 13cc8ad9..e9213d50 100644 --- a/src/main/java/com/chargebee/v4/services/TimeMachineService.java +++ b/src/main/java/com/chargebee/v4/services/TimeMachineService.java @@ -289,8 +289,9 @@ public TimeMachine waitForTimeTravelCompletion(String timeMachineName) if (timeMachine.getTimeTravelStatus() == TimeTravelStatus.FAILED) { String errorJson = timeMachine.getErrorJson(); - int httpStatusCode = JsonUtil.getInteger(errorJson, "http_code"); - String exceptionMessage = JsonUtil.getString(errorJson, "message"); + com.google.gson.JsonObject errorObj = JsonUtil.parse(errorJson); + int httpStatusCode = JsonUtil.getInteger(errorObj, "http_code"); + String exceptionMessage = JsonUtil.getString(errorObj, "message"); throw new OperationFailedException( httpStatusCode, "operation_failed", diff --git a/src/main/java/com/chargebee/v4/transport/HttpStatusHandler.java b/src/main/java/com/chargebee/v4/transport/HttpStatusHandler.java index b79c0120..aab56190 100644 --- a/src/main/java/com/chargebee/v4/transport/HttpStatusHandler.java +++ b/src/main/java/com/chargebee/v4/transport/HttpStatusHandler.java @@ -8,6 +8,7 @@ import com.chargebee.v4.exceptions.*; import com.chargebee.v4.exceptions.codes.*; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonObject; /** * Utility class for handling HTTP status codes and creating appropriate exceptions. This handler @@ -36,12 +37,13 @@ public static void validateResponse(Request request, Response response) throws H String body = response.getBodyAsString(); if (body != null && !body.trim().isEmpty() && body.trim().startsWith("{")) { - boolean hasType = JsonUtil.hasValue(body, "type"); - boolean hasMessage = JsonUtil.hasValue(body, "message"); - boolean hasApiErrorCode = JsonUtil.hasValue(body, "api_error_code"); + JsonObject errorObj = JsonUtil.parse(body); + boolean hasType = JsonUtil.hasValue(errorObj, "type"); + boolean hasMessage = JsonUtil.hasValue(errorObj, "message"); + boolean hasApiErrorCode = JsonUtil.hasValue(errorObj, "api_error_code"); if (hasType || (hasMessage && hasApiErrorCode)) { - throwAPIException(statusCode, body, request, response); + throwAPIException(statusCode, errorObj, body, request, response); return; } } @@ -57,10 +59,11 @@ public static void validateResponse(Request request, Response response) throws H /** Throw appropriate API exception based on error type in JSON response. */ private static void throwAPIException( - int statusCode, String jsonResponse, Request request, Response response) throws APIException { - String type = JsonUtil.getString(jsonResponse, "type"); - String apiErrorCodeStr = JsonUtil.getString(jsonResponse, "api_error_code"); - String message = JsonUtil.getString(jsonResponse, "message"); + int statusCode, JsonObject errorObj, String jsonResponse, Request request, Response response) + throws APIException { + String type = JsonUtil.getString(errorObj, "type"); + String apiErrorCodeStr = JsonUtil.getString(errorObj, "api_error_code"); + String message = JsonUtil.getString(errorObj, "message"); if (message == null) { message = "API Error"; } @@ -179,15 +182,13 @@ private static String extractErrorMessage(String body) { return null; } + JsonObject errorObj = JsonUtil.parse(body); String[] possibleFields = {"message", "error", "error_description", "detail"}; for (String field : possibleFields) { - String pattern = "\"" + field + "\"\\s*:\\s*\"([^\"]+)\""; - java.util.regex.Pattern regex = - java.util.regex.Pattern.compile(pattern, java.util.regex.Pattern.CASE_INSENSITIVE); - java.util.regex.Matcher matcher = regex.matcher(body); - if (matcher.find()) { - return matcher.group(1); + String value = JsonUtil.getString(errorObj, field); + if (value != null && !value.isEmpty()) { + return value; } } diff --git a/src/test/java/com/chargebee/v4/internal/EventParserTest.java b/src/test/java/com/chargebee/v4/internal/EventParserTest.java index 59d92d6f..6669f9db 100644 --- a/src/test/java/com/chargebee/v4/internal/EventParserTest.java +++ b/src/test/java/com/chargebee/v4/internal/EventParserTest.java @@ -6,6 +6,7 @@ import com.chargebee.v4.models.event.Event.*; import com.chargebee.v4.models.invoice.Invoice; import com.chargebee.v4.models.subscription.Subscription; +import com.google.gson.JsonObject; import org.junit.jupiter.api.*; import java.io.IOException; @@ -28,9 +29,10 @@ static void loadFixture() throws IOException { assertNotNull(is, "fixtures/events.json not found on classpath"); raw = new String(is.readAllBytes(), StandardCharsets.UTF_8); } - String eventJson = JsonUtil.getObject(raw, "event"); - assertNotNull(eventJson, "could not extract 'event' wrapper from fixture"); - event = Event.fromJson(eventJson); + JsonObject root = JsonUtil.parse(raw); + JsonObject eventObj = JsonUtil.getJsonObject(root, "event"); + assertNotNull(eventObj, "could not extract 'event' wrapper from fixture"); + event = Event.fromJson(eventObj); } @Nested diff --git a/src/test/java/com/chargebee/v4/internal/JsonUtilTest.java b/src/test/java/com/chargebee/v4/internal/JsonUtilTest.java index 25495514..f9bbaac0 100644 --- a/src/test/java/com/chargebee/v4/internal/JsonUtilTest.java +++ b/src/test/java/com/chargebee/v4/internal/JsonUtilTest.java @@ -13,1089 +13,660 @@ import static org.junit.jupiter.api.Assertions.*; -/** - * Comprehensive test suite for JsonUtil. - * Inspired by Gson's testing strategies to battle-test our JSON parsing. - */ @DisplayName("JsonUtil Tests") class JsonUtilTest { - // ========== getString Tests ========== + // ========== parse / parseToArray ========== + @Nested + @DisplayName("parse Tests") + class ParseTests { + + @Test void validJson() { + JsonObject obj = JsonUtil.parse("{\"id\": \"sub_123\", \"amount\": 1000}"); + assertNotNull(obj); + assertEquals("sub_123", JsonUtil.getString(obj, "id")); + assertEquals(1000L, JsonUtil.getLong(obj, "amount")); + } + + @Test void nullReturnsEmptyObject() { + JsonObject obj = JsonUtil.parse(null); + assertNotNull(obj); + assertTrue(obj.entrySet().isEmpty()); + } + + @Test void emptyStringReturnsEmptyObject() { + assertNotNull(JsonUtil.parse("")); + assertNotNull(JsonUtil.parse(" ")); + } + + @Test void invalidJsonReturnsEmptyObject() { + JsonObject obj = JsonUtil.parse("not json"); + assertNotNull(obj); + assertTrue(obj.entrySet().isEmpty()); + } + + @Test void parseToArrayValid() { + JsonArray arr = JsonUtil.parseToArray("[1, 2, 3]"); + assertNotNull(arr); + assertEquals(3, arr.size()); + } + + @Test void parseToArrayNull() { + JsonArray arr = JsonUtil.parseToArray(null); + assertNotNull(arr); + assertEquals(0, arr.size()); + } + } + + // ========== getString ========== @Nested @DisplayName("getString Tests") class GetStringTests { - @Test - @DisplayName("should extract simple string value") - void shouldExtractSimpleString() { - String json = "{\"name\": \"John\"}"; - assertEquals("John", JsonUtil.getString(json, "name")); + @Test void simpleString() { + JsonObject obj = JsonUtil.parse("{\"name\": \"John\"}"); + assertEquals("John", JsonUtil.getString(obj, "name")); } - @Test - @DisplayName("should extract string with spaces") - void shouldExtractStringWithSpaces() { - String json = "{\"message\": \"Hello World\"}"; - assertEquals("Hello World", JsonUtil.getString(json, "message")); + @Test void stringWithSpaces() { + JsonObject obj = JsonUtil.parse("{\"message\": \"Hello World\"}"); + assertEquals("Hello World", JsonUtil.getString(obj, "message")); } - @Test - @DisplayName("should handle escaped quotes in string") - void shouldHandleEscapedQuotes() { - String json = "{\"text\": \"He said \\\"Hello\\\"\"}"; - assertEquals("He said \"Hello\"", JsonUtil.getString(json, "text")); + @Test void escapedQuotes() { + JsonObject obj = JsonUtil.parse("{\"text\": \"He said \\\"Hello\\\"\"}"); + assertEquals("He said \"Hello\"", JsonUtil.getString(obj, "text")); } - @Test - @DisplayName("should handle escaped backslashes") - void shouldHandleEscapedBackslashes() { - String json = "{\"path\": \"C:\\\\Users\\\\test\"}"; - assertEquals("C:\\Users\\test", JsonUtil.getString(json, "path")); + @Test void escapedBackslashes() { + JsonObject obj = JsonUtil.parse("{\"path\": \"C:\\\\Users\\\\test\"}"); + assertEquals("C:\\Users\\test", JsonUtil.getString(obj, "path")); } - @Test - @DisplayName("should handle newlines and tabs") - void shouldHandleNewlinesAndTabs() { - String json = "{\"text\": \"line1\\nline2\\ttab\"}"; - assertEquals("line1\nline2\ttab", JsonUtil.getString(json, "text")); + @Test void newlinesAndTabs() { + JsonObject obj = JsonUtil.parse("{\"text\": \"line1\\nline2\\ttab\"}"); + assertEquals("line1\nline2\ttab", JsonUtil.getString(obj, "text")); } - @Test - @DisplayName("should return null for missing key") - void shouldReturnNullForMissingKey() { - String json = "{\"name\": \"John\"}"; - assertNull(JsonUtil.getString(json, "missing")); + @Test void missingKeyReturnsNull() { + JsonObject obj = JsonUtil.parse("{\"name\": \"John\"}"); + assertNull(JsonUtil.getString(obj, "missing")); } - @Test - @DisplayName("should return null for null json") - void shouldReturnNullForNullJson() { - assertNull(JsonUtil.getString((String) null, "key")); + @Test void nullObjReturnsNull() { + assertNull(JsonUtil.getString((JsonObject) null, "key")); } - @Test - @DisplayName("should return null for null key") - void shouldReturnNullForNullKey() { - assertNull(JsonUtil.getString("{\"name\": \"John\"}", null)); + @Test void nullKeyReturnsNull() { + JsonObject obj = JsonUtil.parse("{\"name\": \"John\"}"); + assertNull(JsonUtil.getString(obj, null)); } - @Test - @DisplayName("should extract empty string") - void shouldExtractEmptyString() { - String json = "{\"empty\": \"\"}"; - assertEquals("", JsonUtil.getString(json, "empty")); + @Test void emptyString() { + JsonObject obj = JsonUtil.parse("{\"empty\": \"\"}"); + assertEquals("", JsonUtil.getString(obj, "empty")); } - @Test - @DisplayName("should extract string with unicode characters") - void shouldExtractUnicodeString() { - String json = "{\"text\": \"日本語 中文 한국어\"}"; - assertEquals("日本語 中文 한국어", JsonUtil.getString(json, "text")); + @Test void unicode() { + JsonObject obj = JsonUtil.parse("{\"text\": \"日本語 中文 한국어\"}"); + assertEquals("日本語 中文 한국어", JsonUtil.getString(obj, "text")); } - @Test - @DisplayName("should extract string with special JSON characters") - void shouldExtractStringWithSpecialChars() { - String json = "{\"text\": \"test: \\\"value\\\", more\"}"; - assertEquals("test: \"value\", more", JsonUtil.getString(json, "text")); + @Test void colonsInValue() { + JsonObject obj = JsonUtil.parse("{\"url\": \"https://example.com:8080/path\"}"); + assertEquals("https://example.com:8080/path", JsonUtil.getString(obj, "url")); } } - // ========== getLong Tests ========== + // ========== getLong ========== @Nested @DisplayName("getLong Tests") class GetLongTests { - @Test - @DisplayName("should extract positive long") - void shouldExtractPositiveLong() { - String json = "{\"id\": 12345678901234}"; - assertEquals(12345678901234L, JsonUtil.getLong(json, "id")); - } - - @Test - @DisplayName("should extract negative long") - void shouldExtractNegativeLong() { - String json = "{\"value\": -9876543210}"; - assertEquals(-9876543210L, JsonUtil.getLong(json, "value")); + @Test void positiveLong() { + JsonObject obj = JsonUtil.parse("{\"id\": 12345678901234}"); + assertEquals(12345678901234L, JsonUtil.getLong(obj, "id")); } - @Test - @DisplayName("should extract zero") - void shouldExtractZero() { - String json = "{\"count\": 0}"; - assertEquals(0L, JsonUtil.getLong(json, "count")); + @Test void negativeLong() { + JsonObject obj = JsonUtil.parse("{\"value\": -9876543210}"); + assertEquals(-9876543210L, JsonUtil.getLong(obj, "value")); } - @Test - @DisplayName("should return null for missing key") - void shouldReturnNullForMissingKey() { - String json = "{\"id\": 123}"; - assertNull(JsonUtil.getLong(json, "missing")); + @Test void zero() { + JsonObject obj = JsonUtil.parse("{\"count\": 0}"); + assertEquals(0L, JsonUtil.getLong(obj, "count")); } - @Test - @DisplayName("should return null for null json") - void shouldReturnNullForNullJson() { - assertNull(JsonUtil.getLong((String) null, "key")); + @Test void missingKeyReturnsNull() { + JsonObject obj = JsonUtil.parse("{\"id\": 123}"); + assertNull(JsonUtil.getLong(obj, "missing")); } - @Test - @DisplayName("should extract epoch timestamp") - void shouldExtractEpochTimestamp() { - String json = "{\"created_at\": 1605530769}"; - assertEquals(1605530769L, JsonUtil.getLong(json, "created_at")); + @Test void epochTimestamp() { + JsonObject obj = JsonUtil.parse("{\"created_at\": 1605530769}"); + assertEquals(1605530769L, JsonUtil.getLong(obj, "created_at")); } - @Test - @DisplayName("should extract resource_version (large long)") - void shouldExtractResourceVersion() { - String json = "{\"resource_version\": 1605530769000}"; - assertEquals(1605530769000L, JsonUtil.getLong(json, "resource_version")); + @Test void resourceVersion() { + JsonObject obj = JsonUtil.parse("{\"resource_version\": 1605530769000}"); + assertEquals(1605530769000L, JsonUtil.getLong(obj, "resource_version")); } } - // ========== getInteger Tests ========== + // ========== getInteger ========== @Nested @DisplayName("getInteger Tests") class GetIntegerTests { - @Test - @DisplayName("should extract positive integer") - void shouldExtractPositiveInteger() { - String json = "{\"count\": 42}"; - assertEquals(42, JsonUtil.getInteger(json, "count")); + @Test void positiveInteger() { + JsonObject obj = JsonUtil.parse("{\"count\": 42}"); + assertEquals(42, JsonUtil.getInteger(obj, "count")); } - @Test - @DisplayName("should extract negative integer") - void shouldExtractNegativeInteger() { - String json = "{\"offset\": -10}"; - assertEquals(-10, JsonUtil.getInteger(json, "offset")); + @Test void negativeInteger() { + JsonObject obj = JsonUtil.parse("{\"offset\": -10}"); + assertEquals(-10, JsonUtil.getInteger(obj, "offset")); } - @Test - @DisplayName("should return null for missing key") - void shouldReturnNullForMissingKey() { - String json = "{\"count\": 42}"; - assertNull(JsonUtil.getInteger(json, "missing")); + @Test void missingKeyReturnsNull() { + JsonObject obj = JsonUtil.parse("{\"count\": 42}"); + assertNull(JsonUtil.getInteger(obj, "missing")); } } - // ========== getBoolean Tests ========== + // ========== getBoolean ========== @Nested @DisplayName("getBoolean Tests") class GetBooleanTests { - @Test - @DisplayName("should extract true") - void shouldExtractTrue() { - String json = "{\"active\": true}"; - assertTrue(JsonUtil.getBoolean(json, "active")); + @Test void trueValue() { + JsonObject obj = JsonUtil.parse("{\"active\": true}"); + assertTrue(JsonUtil.getBoolean(obj, "active")); } - @Test - @DisplayName("should extract false") - void shouldExtractFalse() { - String json = "{\"deleted\": false}"; - assertFalse(JsonUtil.getBoolean(json, "deleted")); + @Test void falseValue() { + JsonObject obj = JsonUtil.parse("{\"deleted\": false}"); + assertFalse(JsonUtil.getBoolean(obj, "deleted")); } - @Test - @DisplayName("should return null for missing key") - void shouldReturnNullForMissingKey() { - String json = "{\"active\": true}"; - assertNull(JsonUtil.getBoolean(json, "missing")); + @Test void missingKeyReturnsNull() { + JsonObject obj = JsonUtil.parse("{\"active\": true}"); + assertNull(JsonUtil.getBoolean(obj, "missing")); } - @Test - @DisplayName("should return null for null json") - void shouldReturnNullForNullJson() { - assertNull(JsonUtil.getBoolean((String) null, "key")); + @Test void nullObjReturnsNull() { + assertNull(JsonUtil.getBoolean((JsonObject) null, "key")); } } - // ========== getDouble Tests ========== + // ========== getDouble ========== @Nested @DisplayName("getDouble Tests") class GetDoubleTests { - @Test - @DisplayName("should extract positive double") - void shouldExtractPositiveDouble() { - String json = "{\"price\": 99.99}"; - assertEquals(99.99, JsonUtil.getDouble(json, "price"), 0.001); + @Test void positiveDouble() { + JsonObject obj = JsonUtil.parse("{\"price\": 99.99}"); + assertEquals(99.99, JsonUtil.getDouble(obj, "price"), 0.001); } - @Test - @DisplayName("should extract negative double") - void shouldExtractNegativeDouble() { - String json = "{\"balance\": -123.45}"; - assertEquals(-123.45, JsonUtil.getDouble(json, "balance"), 0.001); + @Test void negativeDouble() { + JsonObject obj = JsonUtil.parse("{\"balance\": -123.45}"); + assertEquals(-123.45, JsonUtil.getDouble(obj, "balance"), 0.001); } - @Test - @DisplayName("should extract exchange rate") - void shouldExtractExchangeRate() { - String json = "{\"exchange_rate\": 1.0}"; - assertEquals(1.0, JsonUtil.getDouble(json, "exchange_rate"), 0.001); + @Test void exchangeRate() { + JsonObject obj = JsonUtil.parse("{\"exchange_rate\": 1.0}"); + assertEquals(1.0, JsonUtil.getDouble(obj, "exchange_rate"), 0.001); } - @Test - @DisplayName("should extract integer as double") - void shouldExtractIntegerAsDouble() { - String json = "{\"amount\": 10000}"; - assertEquals(10000.0, JsonUtil.getDouble(json, "amount"), 0.001); + @Test void integerAsDouble() { + JsonObject obj = JsonUtil.parse("{\"amount\": 10000}"); + assertEquals(10000.0, JsonUtil.getDouble(obj, "amount"), 0.001); } } - // ========== getBigDecimal Tests ========== + // ========== getBigDecimal ========== @Nested @DisplayName("getBigDecimal Tests") class GetBigDecimalTests { - @Test - @DisplayName("should extract decimal value") - void shouldExtractDecimalValue() { - String json = "{\"amount\": 1234.56}"; - assertEquals(new BigDecimal("1234.56"), JsonUtil.getBigDecimal(json, "amount")); + @Test void decimalValue() { + JsonObject obj = JsonUtil.parse("{\"amount\": 1234.56}"); + assertEquals(new BigDecimal("1234.56"), JsonUtil.getBigDecimal(obj, "amount")); } - @Test - @DisplayName("should extract integer as BigDecimal") - void shouldExtractIntegerAsBigDecimal() { - String json = "{\"amount\": 10000}"; - assertEquals(new BigDecimal("10000"), JsonUtil.getBigDecimal(json, "amount")); + @Test void integerAsBigDecimal() { + JsonObject obj = JsonUtil.parse("{\"amount\": 10000}"); + assertEquals(new BigDecimal("10000"), JsonUtil.getBigDecimal(obj, "amount")); } } - // ========== getObject Tests ========== + // ========== getTimestamp ========== @Nested - @DisplayName("getObject Tests") - class GetObjectTests { + @DisplayName("getTimestamp Tests") + class GetTimestampTests { - @Test - @DisplayName("should extract simple nested object") - void shouldExtractSimpleNestedObject() { - String json = "{\"customer\": {\"id\": \"cust_123\", \"name\": \"John\"}}"; - String result = JsonUtil.getObject(json, "customer"); + @Test void epochSecondsToTimestamp() { + JsonObject obj = JsonUtil.parse("{\"created_at\": 1605530769}"); + Timestamp result = JsonUtil.getTimestamp(obj, "created_at"); assertNotNull(result); - assertEquals("cust_123", JsonUtil.getString(result, "id")); - assertEquals("John", JsonUtil.getString(result, "name")); - } - - @Test - @DisplayName("should extract deeply nested object") - void shouldExtractDeeplyNestedObject() { - String json = "{\"data\": {\"customer\": {\"address\": {\"city\": \"NYC\"}}}}"; - String dataObj = JsonUtil.getObject(json, "data"); - assertNotNull(dataObj); - String customerObj = JsonUtil.getObject(dataObj, "customer"); - assertNotNull(customerObj); - String addressObj = JsonUtil.getObject(customerObj, "address"); - assertNotNull(addressObj); - assertEquals("NYC", JsonUtil.getString(addressObj, "city")); - } - - @Test - @DisplayName("should handle object with nested arrays") - void shouldHandleObjectWithNestedArrays() { - String json = "{\"transaction\": {\"id\": \"txn_123\", \"linked_invoices\": [{\"id\": \"inv_1\"}]}}"; - String result = JsonUtil.getObject(json, "transaction"); - assertNotNull(result); - assertTrue(result.contains("linked_invoices")); - assertTrue(result.contains("inv_1")); + assertEquals(1605530769000L, result.getTime()); } - @Test - @DisplayName("should handle object with escaped strings") - void shouldHandleObjectWithEscapedStrings() { - String json = "{\"data\": {\"text\": \"Hello \\\"World\\\"\"}}"; - String result = JsonUtil.getObject(json, "data"); - assertNotNull(result); - assertTrue(result.contains("Hello \\\"World\\\"")); + @Test void missingKeyReturnsNull() { + JsonObject obj = JsonUtil.parse("{\"updated_at\": 1605530769}"); + assertNull(JsonUtil.getTimestamp(obj, "created_at")); } + } - @Test - @DisplayName("should return null for missing key") - void shouldReturnNullForMissingKey() { - String json = "{\"customer\": {\"id\": \"123\"}}"; - assertNull(JsonUtil.getObject(json, "missing")); + // ========== getJsonObject / getObject ========== + @Nested + @DisplayName("getJsonObject / getObject Tests") + class GetObjectTests { + + @Test void getJsonObjectNested() { + JsonObject root = JsonUtil.parse("{\"customer\": {\"id\": \"cust_1\", \"email\": \"a@b.com\"}}"); + JsonObject customer = JsonUtil.getJsonObject(root, "customer"); + assertNotNull(customer); + assertEquals("cust_1", JsonUtil.getString(customer, "id")); + assertEquals("a@b.com", JsonUtil.getString(customer, "email")); } - @Test - @DisplayName("should return null when value is not object") - void shouldReturnNullWhenNotObject() { - String json = "{\"name\": \"John\"}"; - assertNull(JsonUtil.getObject(json, "name")); + @Test void getJsonObjectMissingReturnsNull() { + JsonObject obj = JsonUtil.parse("{\"name\": \"test\"}"); + assertNull(JsonUtil.getJsonObject(obj, "missing")); } - @Test - @DisplayName("should extract empty object") - void shouldExtractEmptyObject() { - String json = "{\"metadata\": {}}"; - assertEquals("{}", JsonUtil.getObject(json, "metadata")); + @Test void getJsonObjectNonObjectReturnsNull() { + JsonObject obj = JsonUtil.parse("{\"name\": \"test\"}"); + assertNull(JsonUtil.getJsonObject(obj, "name")); + } + + @Test void getObjectReturnsJsonString() { + JsonObject root = JsonUtil.parse("{\"meta\": {\"key\": \"val\"}}"); + String meta = JsonUtil.getObject(root, "meta"); + assertNotNull(meta); + assertTrue(meta.contains("key")); + assertTrue(meta.contains("val")); + } + + @Test void getObjectDeeplyNested() { + JsonObject root = JsonUtil.parse("{\"data\": {\"customer\": {\"address\": {\"city\": \"NYC\"}}}}"); + JsonObject data = JsonUtil.getJsonObject(root, "data"); + JsonObject customer = JsonUtil.getJsonObject(data, "customer"); + JsonObject address = JsonUtil.getJsonObject(customer, "address"); + assertEquals("NYC", JsonUtil.getString(address, "city")); + } + + @Test void getObjectEmptyObject() { + JsonObject obj = JsonUtil.parse("{\"metadata\": {}}"); + assertEquals("{}", JsonUtil.getObject(obj, "metadata")); + } + + @Test void getObjectNonObjectReturnsNull() { + JsonObject obj = JsonUtil.parse("{\"name\": \"John\"}"); + assertNull(JsonUtil.getObject(obj, "name")); } } - // ========== getArray Tests - THE CRITICAL FIX ========== + // ========== getJsonArray / getArray ========== @Nested - @DisplayName("getArray Tests") + @DisplayName("getJsonArray / getArray Tests") class GetArrayTests { - @Test - @DisplayName("should extract simple array of strings") - void shouldExtractSimpleArrayOfStrings() { - String json = "{\"tags\": [\"a\", \"b\", \"c\"]}"; - String result = JsonUtil.getArray(json, "tags"); - assertNotNull(result); - List parsed = JsonUtil.parseArrayOfString(result); - assertEquals(3, parsed.size()); - assertEquals("a", parsed.get(0)); - assertEquals("b", parsed.get(1)); - assertEquals("c", parsed.get(2)); + @Test void getJsonArrayValid() { + JsonObject root = JsonUtil.parse("{\"items\": [{\"id\": \"item_1\"}, {\"id\": \"item_2\"}]}"); + JsonArray items = JsonUtil.getJsonArray(root, "items"); + assertNotNull(items); + assertEquals(2, items.size()); + assertEquals("item_1", items.get(0).getAsJsonObject().get("id").getAsString()); } - @Test - @DisplayName("should extract empty array") - void shouldExtractEmptyArray() { - String json = "{\"items\": []}"; - assertEquals("[]", JsonUtil.getArray(json, "items")); + @Test void getJsonArrayMissingReturnsNull() { + JsonObject obj = JsonUtil.parse("{\"name\": \"test\"}"); + assertNull(JsonUtil.getJsonArray(obj, "missing")); } - @Test - @DisplayName("should extract array of objects") - void shouldExtractArrayOfObjects() { - String json = "{\"list\": [{\"id\": 1}, {\"id\": 2}]}"; - String result = JsonUtil.getArray(json, "list"); - assertNotNull(result); - assertTrue(result.startsWith("[")); - assertTrue(result.endsWith("]")); - List objects = JsonUtil.parseObjectArray(result); - assertEquals(2, objects.size()); - assertEquals(1, JsonUtil.getInteger(objects.get(0), "id")); - assertEquals(2, JsonUtil.getInteger(objects.get(1), "id")); - } - - @Test - @DisplayName("should handle array with nested arrays - THE BUG FIX TEST") - void shouldHandleArrayWithNestedArrays() { - // This is the exact case that was failing before the fix! - String json = "{\"list\": [{\"transaction\": {\"linked_invoices\": [{\"id\": \"inv_1\"}], \"linked_refunds\": []}}]}"; - String result = JsonUtil.getArray(json, "list"); + @Test void getArrayReturnsJsonString() { + JsonObject obj = JsonUtil.parse("{\"tags\": [\"a\", \"b\"]}"); + String tags = JsonUtil.getArray(obj, "tags"); + assertNotNull(tags); + assertTrue(tags.startsWith("[")); + assertTrue(tags.endsWith("]")); + } + + @Test void getArrayEmpty() { + JsonObject obj = JsonUtil.parse("{\"items\": []}"); + assertEquals("[]", JsonUtil.getArray(obj, "items")); + } + + @Test void getArrayNestedStructures() { + JsonObject root = JsonUtil.parse( + "{\"list\": [{\"transaction\": {\"linked_invoices\": [{\"id\": \"inv_1\"}], \"linked_refunds\": []}}]}"); + String result = JsonUtil.getArray(root, "list"); assertNotNull(result); - assertTrue(result.startsWith("[")); - assertTrue(result.endsWith("]")); - // Verify the entire array is extracted, not truncated at first ] assertTrue(result.contains("linked_invoices")); assertTrue(result.contains("linked_refunds")); assertTrue(result.contains("inv_1")); } - @Test - @DisplayName("should handle complex nested structure from transaction API") - void shouldHandleComplexNestedStructure() { - // Real-world example from the bug report - String json = "{\"list\": [{\"transaction\": {" + - "\"id\": \"txn_AzZhUGSPAkLskJQo\"," + - "\"customer_id\": \"cbdemo_dave\"," + - "\"amount\": 10000," + - "\"linked_invoices\": [{" + - "\"invoice_id\": \"DemoInv_103\"," + - "\"applied_amount\": 10000," + - "\"applied_at\": 1605530769" + - "}]," + - "\"linked_refunds\": []," + - "\"payment_method_details\": \"{\\\"card\\\":{\\\"iin\\\":\\\"555555\\\"}}\"" + - "}}]}"; - - String result = JsonUtil.getArray(json, "list"); - assertNotNull(result); - assertTrue(result.startsWith("[")); - assertTrue(result.endsWith("]")); - - // Critical: verify we got the complete array, not truncated - assertTrue(result.contains("txn_AzZhUGSPAkLskJQo")); - assertTrue(result.contains("linked_invoices")); - assertTrue(result.contains("DemoInv_103")); - assertTrue(result.contains("linked_refunds")); + @Test void getArrayNonArrayReturnsNull() { + JsonObject obj = JsonUtil.parse("{\"name\": \"John\"}"); + assertNull(JsonUtil.getArray(obj, "name")); } + } - @Test - @DisplayName("should handle array with deeply nested objects") - void shouldHandleArrayWithDeeplyNestedObjects() { - String json = "{\"data\": [{\"level1\": {\"level2\": {\"level3\": [{\"value\": 1}]}}}]}"; - String result = JsonUtil.getArray(json, "data"); - assertNotNull(result); - assertTrue(result.contains("level1")); - assertTrue(result.contains("level2")); - assertTrue(result.contains("level3")); - assertTrue(result.contains("value")); + // ========== hasValue ========== + @Nested + @DisplayName("hasValue Tests") + class HasValueTests { + + @Test void existingNonNullValue() { + JsonObject obj = JsonUtil.parse("{\"name\": \"John\", \"age\": 30}"); + assertTrue(JsonUtil.hasValue(obj, "name")); + assertTrue(JsonUtil.hasValue(obj, "age")); } - @Test - @DisplayName("should handle array with escaped strings containing brackets") - void shouldHandleArrayWithEscapedBrackets() { - String json = "{\"messages\": [\"text with [brackets]\", \"another [one]\"]}"; - String result = JsonUtil.getArray(json, "messages"); - assertNotNull(result); - assertTrue(result.contains("[brackets]")); - assertTrue(result.contains("[one]")); + @Test void nullValueReturnsFalse() { + JsonObject obj = JsonUtil.parse("{\"name\": null}"); + assertFalse(JsonUtil.hasValue(obj, "name")); } - @Test - @DisplayName("should handle array with JSON string field containing brackets") - void shouldHandleArrayWithJsonStringField() { - // payment_method_details contains a JSON string with brackets - String json = "{\"list\": [{\"details\": \"{\\\"array\\\":[1,2,3]}\"}]}"; - String result = JsonUtil.getArray(json, "list"); - assertNotNull(result); - assertTrue(result.contains("details")); + @Test void missingKeyReturnsFalse() { + JsonObject obj = JsonUtil.parse("{\"name\": \"John\"}"); + assertFalse(JsonUtil.hasValue(obj, "missing")); } + } + + // ========== parseJsonObjectToMap ========== + @Nested + @DisplayName("parseJsonObjectToMap Tests") + class ParseJsonObjectToMapTests { - @Test - @DisplayName("should return null for missing array key") - void shouldReturnNullForMissingKey() { - String json = "{\"data\": [1, 2, 3]}"; - assertNull(JsonUtil.getArray(json, "missing")); + @Test void simpleObjectToMap() { + JsonObject obj = JsonUtil.parse("{\"name\": \"John\", \"age\": 30, \"active\": true}"); + Map map = JsonUtil.parseJsonObjectToMap(obj); + assertEquals("John", map.get("name")); + assertEquals(30L, map.get("age")); + assertEquals(true, map.get("active")); } - @Test - @DisplayName("should return null when value is not array") - void shouldReturnNullWhenNotArray() { - String json = "{\"name\": \"John\"}"; - assertNull(JsonUtil.getArray(json, "name")); + @Test void nestedObjectsAsStrings() { + JsonObject obj = JsonUtil.parse("{\"user\": {\"name\": \"John\"}}"); + Map map = JsonUtil.parseJsonObjectToMap(obj); + assertTrue(map.get("user") instanceof String); + assertTrue(((String) map.get("user")).contains("name")); } - @Test - @DisplayName("should handle multiple arrays in same object") - void shouldHandleMultipleArrays() { - String json = "{\"first\": [1, 2], \"second\": [3, 4], \"third\": [5, 6]}"; - List first = JsonUtil.parseArrayOfInteger(JsonUtil.getArray(json, "first")); - assertEquals(2, first.size()); - assertEquals(1, first.get(0)); - assertEquals(2, first.get(1)); + @Test void arraysAsStrings() { + JsonObject obj = JsonUtil.parse("{\"tags\": [\"a\", \"b\"]}"); + Map map = JsonUtil.parseJsonObjectToMap(obj); + assertTrue(map.get("tags") instanceof String); + assertTrue(((String) map.get("tags")).contains("\"a\"")); + } - List second = JsonUtil.parseArrayOfInteger(JsonUtil.getArray(json, "second")); - assertEquals(2, second.size()); - assertEquals(3, second.get(0)); + @Test void nullReturnsEmptyMap() { + Map map = JsonUtil.parseJsonObjectToMap((JsonObject) null); + assertTrue(map.isEmpty()); + } - List third = JsonUtil.parseArrayOfInteger(JsonUtil.getArray(json, "third")); - assertEquals(2, third.size()); - assertEquals(5, third.get(0)); + @Test void nullValuesPreserved() { + JsonObject obj = JsonUtil.parse("{\"value\": null}"); + Map map = JsonUtil.parseJsonObjectToMap(obj); + assertTrue(map.containsKey("value")); + assertNull(map.get("value")); } - @Test - @DisplayName("should handle array with null values") - void shouldHandleArrayWithNulls() { - String json = "{\"values\": [null, \"a\", null, \"b\"]}"; - String result = JsonUtil.getArray(json, "values"); + @Test void doubleValues() { + JsonObject obj = JsonUtil.parse("{\"price\": 99.99}"); + Map map = JsonUtil.parseJsonObjectToMap(obj); + assertEquals(99.99, (Double) map.get("price"), 0.001); + } + } + + // ========== mapArray ========== + @Nested + @DisplayName("mapArray Tests") + class MapArrayTests { + + @Test void mapsElements() { + JsonArray array = JsonUtil.parseToArray("[{\"id\": \"a\"}, {\"id\": \"b\"}, {\"id\": \"c\"}]"); + List ids = JsonUtil.mapArray(array, obj -> JsonUtil.getString(obj, "id")); + assertEquals(3, ids.size()); + assertEquals("a", ids.get(0)); + assertEquals("b", ids.get(1)); + assertEquals("c", ids.get(2)); + } + + @Test void nullReturnsEmptyList() { + List result = JsonUtil.mapArray(null, obj -> "x"); assertNotNull(result); - assertTrue(result.contains("null")); + assertTrue(result.isEmpty()); } } - // ========== parseObjectArray Tests ========== + // ========== mapArrayToObjects / mapArrayToMaps ========== @Nested - @DisplayName("parseObjectArray Tests") - class ParseObjectArrayTests { - - @Test - @DisplayName("should parse array of simple objects") - void shouldParseArrayOfSimpleObjects() { - String arrayJson = "[{\"id\": 1}, {\"id\": 2}, {\"id\": 3}]"; - List objects = JsonUtil.parseObjectArray(arrayJson); - assertEquals(3, objects.size()); - assertEquals(1, JsonUtil.getInteger(objects.get(0), "id")); - assertEquals(2, JsonUtil.getInteger(objects.get(1), "id")); - assertEquals(3, JsonUtil.getInteger(objects.get(2), "id")); - } - - @Test - @DisplayName("should parse array of complex objects") - void shouldParseArrayOfComplexObjects() { - String arrayJson = "[{\"transaction\": {\"id\": \"txn_1\", \"items\": [1, 2]}}, {\"transaction\": {\"id\": \"txn_2\"}}]"; - List objects = JsonUtil.parseObjectArray(arrayJson); - assertEquals(2, objects.size()); - assertTrue(objects.get(0).contains("txn_1")); - assertTrue(objects.get(1).contains("txn_2")); - } - - @Test - @DisplayName("should return empty list for null input") - void shouldReturnEmptyListForNull() { - List objects = JsonUtil.parseObjectArray(null); - assertTrue(objects.isEmpty()); - } - - @Test - @DisplayName("should return empty list for empty array") - void shouldReturnEmptyListForEmptyArray() { - List objects = JsonUtil.parseObjectArray("[]"); - assertTrue(objects.isEmpty()); - } - - @Test - @DisplayName("should return empty list for non-array input") - void shouldReturnEmptyListForNonArray() { - List objects = JsonUtil.parseObjectArray("{\"id\": 1}"); - assertTrue(objects.isEmpty()); - } - - @Test - @DisplayName("should handle objects with escaped strings") - void shouldHandleObjectsWithEscapedStrings() { - String arrayJson = "[{\"text\": \"Hello \\\"World\\\"\"}]"; - List objects = JsonUtil.parseObjectArray(arrayJson); - assertEquals(1, objects.size()); - assertTrue(objects.get(0).contains("Hello \\\"World\\\"")); + @DisplayName("mapArrayToObjects / mapArrayToMaps Tests") + class MapArrayToTests { + + @Test void mapArrayToMaps() { + JsonArray array = JsonUtil.parseToArray("[{\"k1\": \"v1\"}, {\"k2\": 42}]"); + List> maps = JsonUtil.mapArrayToMaps(array); + assertEquals(2, maps.size()); + assertEquals("v1", maps.get(0).get("k1")); + assertEquals(42L, maps.get(1).get("k2")); + } + + @Test void mapArrayToObjects() { + JsonArray array = JsonUtil.parseToArray("[{\"k\": \"v\"}, 42, \"text\", null]"); + List objs = JsonUtil.mapArrayToObjects(array); + assertEquals(4, objs.size()); + assertTrue(objs.get(0) instanceof Map); + assertEquals(42L, objs.get(1)); + assertEquals("text", objs.get(2)); + assertNull(objs.get(3)); } } - // ========== parseArrayOf* Tests ========== + // ========== parseArrayOf* ========== @Nested @DisplayName("parseArrayOf* Tests") class ParseArrayOfTests { - @Test - @DisplayName("should parse array of strings") - void shouldParseArrayOfStrings() { - String arrayJson = "[\"a\", \"b\", \"c\"]"; - List result = JsonUtil.parseArrayOfString(arrayJson); + @Test void strings() { + JsonArray arr = JsonUtil.parseToArray("[\"a\", \"b\", \"c\"]"); + List result = JsonUtil.parseArrayOfString(arr); assertEquals(3, result.size()); assertEquals("a", result.get(0)); - assertEquals("b", result.get(1)); - assertEquals("c", result.get(2)); } - @Test - @DisplayName("should parse array of integers") - void shouldParseArrayOfIntegers() { - String arrayJson = "[1, 2, 3, -4, 0]"; - List result = JsonUtil.parseArrayOfInteger(arrayJson); + @Test void integers() { + JsonArray arr = JsonUtil.parseToArray("[1, 2, 3, -4, 0]"); + List result = JsonUtil.parseArrayOfInteger(arr); assertEquals(5, result.size()); assertEquals(1, result.get(0)); assertEquals(-4, result.get(3)); assertEquals(0, result.get(4)); } - @Test - @DisplayName("should parse array of longs") - void shouldParseArrayOfLongs() { - String arrayJson = "[1605530769000, 1605530770000]"; - List result = JsonUtil.parseArrayOfLong(arrayJson); + @Test void longs() { + JsonArray arr = JsonUtil.parseToArray("[1605530769000, 1605530770000]"); + List result = JsonUtil.parseArrayOfLong(arr); assertEquals(2, result.size()); assertEquals(1605530769000L, result.get(0)); } - @Test - @DisplayName("should parse array of booleans") - void shouldParseArrayOfBooleans() { - String arrayJson = "[true, false, true]"; - List result = JsonUtil.parseArrayOfBoolean(arrayJson); + @Test void booleans() { + JsonArray arr = JsonUtil.parseToArray("[true, false, true]"); + List result = JsonUtil.parseArrayOfBoolean(arr); assertEquals(3, result.size()); assertTrue(result.get(0)); assertFalse(result.get(1)); - assertTrue(result.get(2)); } - @Test - @DisplayName("should parse array of doubles") - void shouldParseArrayOfDoubles() { - String arrayJson = "[1.5, 2.7, 3.14]"; - List result = JsonUtil.parseArrayOfDouble(arrayJson); + @Test void doubles() { + JsonArray arr = JsonUtil.parseToArray("[1.5, 2.7, 3.14]"); + List result = JsonUtil.parseArrayOfDouble(arr); assertEquals(3, result.size()); assertEquals(1.5, result.get(0), 0.001); } - @Test - @DisplayName("should parse array of BigDecimal") - void shouldParseArrayOfBigDecimal() { - String arrayJson = "[123.45, 678.90]"; - List result = JsonUtil.parseArrayOfBigDecimal(arrayJson); + @Test void bigDecimals() { + JsonArray arr = JsonUtil.parseToArray("[123.45, 678.90]"); + List result = JsonUtil.parseArrayOfBigDecimal(arr); assertEquals(2, result.size()); } - @Test - @DisplayName("should return empty list for empty arrays") - void shouldReturnEmptyListForEmptyArrays() { - assertTrue(JsonUtil.parseArrayOfString("[]").isEmpty()); - assertTrue(JsonUtil.parseArrayOfInteger("[]").isEmpty()); - assertTrue(JsonUtil.parseArrayOfLong("[]").isEmpty()); - assertTrue(JsonUtil.parseArrayOfBoolean("[]").isEmpty()); - assertTrue(JsonUtil.parseArrayOfDouble("[]").isEmpty()); - } - - @Test - @DisplayName("should return empty list for null input") - void shouldReturnEmptyListForNull() { - assertTrue(JsonUtil.parseArrayOfString((String) null).isEmpty()); - assertTrue(JsonUtil.parseArrayOfInteger((String) null).isEmpty()); - } - } - - // ========== getTimestamp Tests ========== - @Nested - @DisplayName("getTimestamp Tests") - class GetTimestampTests { - - @Test - @DisplayName("should parse epoch seconds to timestamp") - void shouldParseEpochSecondsToTimestamp() { - String json = "{\"created_at\": 1605530769}"; - Timestamp result = JsonUtil.getTimestamp(json, "created_at"); - assertNotNull(result); - assertEquals(1605530769000L, result.getTime()); - } - - @Test - @DisplayName("should return null for missing key") - void shouldReturnNullForMissingKey() { - String json = "{\"updated_at\": 1605530769}"; - assertNull(JsonUtil.getTimestamp(json, "created_at")); + @Test void nullReturnsEmptyLists() { + assertTrue(JsonUtil.parseArrayOfString((JsonArray) null).isEmpty()); + assertTrue(JsonUtil.parseArrayOfInteger((JsonArray) null).isEmpty()); + assertTrue(JsonUtil.parseArrayOfLong((JsonArray) null).isEmpty()); + assertTrue(JsonUtil.parseArrayOfBoolean((JsonArray) null).isEmpty()); + assertTrue(JsonUtil.parseArrayOfDouble((JsonArray) null).isEmpty()); + assertTrue(JsonUtil.parseArrayOfBigDecimal((JsonArray) null).isEmpty()); } } - // ========== hasValue Tests ========== + // ========== extractCustomFields / extractConsentFields ========== @Nested - @DisplayName("hasValue Tests") - class HasValueTests { - - @Test - @DisplayName("should return true for existing non-null value") - void shouldReturnTrueForExistingValue() { - String json = "{\"name\": \"John\", \"age\": 30}"; - assertTrue(JsonUtil.hasValue(json, "name")); - assertTrue(JsonUtil.hasValue(json, "age")); - } - - @Test - @DisplayName("should return false for null value") - void shouldReturnFalseForNullValue() { - String json = "{\"name\": null}"; - assertFalse(JsonUtil.hasValue(json, "name")); - } - - @Test - @DisplayName("should return false for missing key") - void shouldReturnFalseForMissingKey() { - String json = "{\"name\": \"John\"}"; - assertFalse(JsonUtil.hasValue(json, "missing")); - } - } - - // ========== parseJsonObjectToMap Tests ========== - @Nested - @DisplayName("parseJsonObjectToMap Tests") - class ParseJsonObjectToMapTests { - - @Test - @DisplayName("should parse simple object to map") - void shouldParseSimpleObjectToMap() { - String json = "{\"name\": \"John\", \"age\": 30, \"active\": true}"; - Map map = JsonUtil.parseJsonObjectToMap(json); - assertEquals("John", map.get("name")); - assertEquals(30L, map.get("age")); - assertEquals(true, map.get("active")); - } - - @Test - @DisplayName("should handle nested objects") - void shouldHandleNestedObjects() { - String json = "{\"user\": {\"name\": \"John\"}}"; - Map map = JsonUtil.parseJsonObjectToMap(json); - assertTrue(map.get("user") instanceof String); - assertTrue(((String) map.get("user")).contains("name")); - } - - @Test - @DisplayName("should handle arrays in map") - void shouldHandleArraysInMap() { - String json = "{\"tags\": [\"a\", \"b\"]}"; - Map map = JsonUtil.parseJsonObjectToMap(json); - assertTrue(map.get("tags") instanceof String); - assertTrue(((String) map.get("tags")).contains("\"a\"")); - } + @DisplayName("extractCustomFields / extractConsentFields Tests") + class ExtractFieldsTests { - @Test - @DisplayName("should return empty map for empty object") - void shouldReturnEmptyMapForEmptyObject() { - Map map = JsonUtil.parseJsonObjectToMap("{}"); - assertTrue(map.isEmpty()); + @Test void extractsCustomFields() { + JsonObject obj = JsonUtil.parse("{\"id\": \"sub_1\", \"cf_color\": \"blue\", \"cf_size\": \"large\", \"name\": \"test\"}"); + Set known = new HashSet<>(); + known.add("id"); + known.add("name"); + Map cf = JsonUtil.extractCustomFields(obj, known); + assertEquals(2, cf.size()); + assertEquals("blue", cf.get("cf_color")); + assertEquals("large", cf.get("cf_size")); } - @Test - @DisplayName("should return empty map for null") - void shouldReturnEmptyMapForNull() { - Map map = JsonUtil.parseJsonObjectToMap((String) null); - assertTrue(map.isEmpty()); + @Test void customFieldNullValues() { + JsonObject obj = JsonUtil.parse("{\"cf_nullable\": null}"); + Map cf = JsonUtil.extractCustomFields(obj, new HashSet<>()); + assertEquals(1, cf.size()); + assertNull(cf.get("cf_nullable")); } - @Test - @DisplayName("should handle null values") - void shouldHandleNullValues() { - String json = "{\"value\": null}"; - Map map = JsonUtil.parseJsonObjectToMap(json); - assertTrue(map.containsKey("value")); - assertNull(map.get("value")); + @Test void excludesKnownCustomFields() { + JsonObject obj = JsonUtil.parse("{\"cf_known\": \"val\"}"); + Set known = new HashSet<>(); + known.add("cf_known"); + Map cf = JsonUtil.extractCustomFields(obj, known); + assertTrue(cf.isEmpty()); } - @Test - @DisplayName("should handle double values") - void shouldHandleDoubleValues() { - String json = "{\"price\": 99.99}"; - Map map = JsonUtil.parseJsonObjectToMap(json); - assertEquals(99.99, (Double) map.get("price"), 0.001); + @Test void extractsConsentFields() { + JsonObject obj = JsonUtil.parse("{\"id\": \"cust_1\", \"cs_marketing\": true, \"cs_analytics\": false}"); + Set known = new HashSet<>(); + known.add("id"); + Map cs = JsonUtil.extractConsentFields(obj, known); + assertEquals(2, cs.size()); + assertEquals(true, cs.get("cs_marketing")); + assertEquals(false, cs.get("cs_analytics")); } } - // ========== toJson Tests ========== + // ========== toJson ========== @Nested @DisplayName("toJson Tests") class ToJsonTests { - @Test - @DisplayName("should serialize map to JSON") - void shouldSerializeMapToJson() { + @Test void serializeMap() { Map map = new java.util.LinkedHashMap<>(); map.put("name", "John"); map.put("age", 30); - String json = JsonUtil.toJson(map); assertTrue(json.contains("\"name\":\"John\"")); assertTrue(json.contains("\"age\":30")); } - @Test - @DisplayName("should serialize list to JSON") - void shouldSerializeListToJson() { + @Test void serializeList() { List list = java.util.Arrays.asList("a", "b", "c"); - String json = JsonUtil.toJson(list); - assertEquals("[\"a\",\"b\",\"c\"]", json); + assertEquals("[\"a\",\"b\",\"c\"]", JsonUtil.toJson(list)); } - @Test - @DisplayName("should serialize empty map") - void shouldSerializeEmptyMap() { + @Test void serializeEmptyMap() { assertEquals("{}", JsonUtil.toJson(new java.util.HashMap<>())); } - @Test - @DisplayName("should serialize empty list") - void shouldSerializeEmptyList() { + @Test void serializeEmptyList() { assertEquals("[]", JsonUtil.toJson(new java.util.ArrayList<>())); } - @Test - @DisplayName("should escape special characters") - void shouldEscapeSpecialCharacters() { + @Test void escapeSpecialCharacters() { Map map = new java.util.HashMap<>(); map.put("text", "Hello \"World\"\nNew line"); - String json = JsonUtil.toJson(map); assertTrue(json.contains("\\\"World\\\"")); assertTrue(json.contains("\\n")); } - @Test - @DisplayName("should serialize null values") - void shouldSerializeNullValues() { + @Test void serializeNullValues() { Map map = new java.util.HashMap<>(); map.put("value", null); - String json = JsonUtil.toJson(map); assertTrue(json.contains("\"value\":null")); } - @Test - @DisplayName("should serialize nested structures") - void shouldSerializeNestedStructures() { + @Test void serializeNestedStructures() { Map inner = new java.util.HashMap<>(); inner.put("id", 123); - Map outer = new java.util.HashMap<>(); outer.put("data", inner); - String json = JsonUtil.toJson(outer); assertTrue(json.contains("\"data\":{")); assertTrue(json.contains("\"id\":123")); } } - // ========== Edge Cases and Real-World Scenarios ========== + // ========== Edge Cases ========== @Nested - @DisplayName("Real-World Scenarios") - class RealWorldScenarios { - - @Test - @DisplayName("should parse transaction list response correctly") - void shouldParseTransactionListResponse() { - String json = "{" + - "\"list\": [{\"transaction\": {" + - "\"id\": \"txn_AzZhUGSPAkLskJQo\"," + - "\"customer_id\": \"cbdemo_dave\"," + - "\"subscription_id\": \"cbdemo_dave-sub1\"," + - "\"gateway_account_id\": \"gw_AzZhUGSPAkLeQJPg\"," + - "\"payment_method\": \"card\"," + - "\"gateway\": \"chargebee\"," + - "\"type\": \"payment\"," + - "\"date\": 1605530769," + - "\"exchange_rate\": 1.0," + - "\"amount\": 10000," + - "\"id_at_gateway\": \"cb___dev__KyVnqiSIrqRVUEN\"," + - "\"status\": \"success\"," + - "\"updated_at\": 1605530769," + - "\"resource_version\": 1605530769000," + - "\"deleted\": false," + - "\"object\": \"transaction\"," + - "\"masked_card_number\": \"************4444\"," + - "\"currency_code\": \"USD\"," + - "\"base_currency_code\": \"USD\"," + - "\"amount_unused\": 0," + - "\"linked_invoices\": [{" + - "\"invoice_id\": \"DemoInv_103\"," + - "\"applied_amount\": 10000," + - "\"applied_at\": 1605530769," + - "\"invoice_date\": 1605530769," + - "\"invoice_total\": 10000," + - "\"invoice_status\": \"paid\"" + - "}]," + - "\"linked_refunds\": []," + - "\"payment_method_details\": \"{\\\"card\\\":{\\\"iin\\\":\\\"555555\\\",\\\"last4\\\":\\\"4444\\\"}}\"" + - "}}]," + - "\"next_offset\": null" + - "}"; - - // Test getArray with nested structures - String listArray = JsonUtil.getArray(json, "list"); - assertNotNull(listArray, "list array should not be null"); - assertTrue(listArray.startsWith("["), "Should start with ["); - assertTrue(listArray.endsWith("]"), "Should end with ]"); - - // Verify it contains the complete transaction data - assertTrue(listArray.contains("txn_AzZhUGSPAkLskJQo")); - assertTrue(listArray.contains("linked_invoices")); - assertTrue(listArray.contains("DemoInv_103")); - assertTrue(listArray.contains("linked_refunds")); - assertTrue(listArray.contains("payment_method_details")); - - // Test parseObjectArray - List objects = JsonUtil.parseObjectArray(listArray); - assertEquals(1, objects.size()); - - // Test nested object extraction - String transactionWrapper = objects.get(0); - String transaction = JsonUtil.getObject(transactionWrapper, "transaction"); - assertNotNull(transaction); - - assertEquals("txn_AzZhUGSPAkLskJQo", JsonUtil.getString(transaction, "id")); - assertEquals("cbdemo_dave", JsonUtil.getString(transaction, "customer_id")); - assertEquals(10000, JsonUtil.getInteger(transaction, "amount")); - assertEquals(1.0, JsonUtil.getDouble(transaction, "exchange_rate"), 0.001); - assertFalse(JsonUtil.getBoolean(transaction, "deleted")); - assertEquals(1605530769000L, JsonUtil.getLong(transaction, "resource_version")); - - // Test nested array extraction - String linkedInvoices = JsonUtil.getArray(transaction, "linked_invoices"); - assertNotNull(linkedInvoices); - assertTrue(linkedInvoices.contains("DemoInv_103")); - - String linkedRefunds = JsonUtil.getArray(transaction, "linked_refunds"); - assertNotNull(linkedRefunds); - assertEquals("[]", linkedRefunds); - } - - @Test - @DisplayName("should handle customer list response") - void shouldHandleCustomerListResponse() { - String json = "{" + - "\"list\": [" + - "{\"customer\": {\"id\": \"cust_123\", \"email\": \"test@example.com\"}}," + - "{\"customer\": {\"id\": \"cust_456\", \"email\": \"user@example.com\"}}" + - "]," + - "\"next_offset\": \"offset_abc123\"" + - "}"; + @DisplayName("Edge Cases") + class EdgeCases { - String listArray = JsonUtil.getArray(json, "list"); - assertNotNull(listArray); - - List items = JsonUtil.parseObjectArray(listArray); - assertEquals(2, items.size()); - - String customer1 = JsonUtil.getObject(items.get(0), "customer"); - assertEquals("cust_123", JsonUtil.getString(customer1, "id")); - - String nextOffset = JsonUtil.getString(json, "next_offset"); - assertEquals("offset_abc123", nextOffset); + @Test void whitespaceVariations() { + assertEquals("value", JsonUtil.getString(JsonUtil.parse("{\"key\":\"value\"}"), "key")); + assertEquals("value", JsonUtil.getString(JsonUtil.parse("{ \"key\" : \"value\" }"), "key")); + assertEquals("value", JsonUtil.getString(JsonUtil.parse("{\n \"key\"\t:\n \"value\"\n}"), "key")); } - @Test - @DisplayName("should handle subscription with multiple nested arrays") - void shouldHandleSubscriptionWithMultipleNestedArrays() { - String json = "{" + - "\"subscription\": {" + - "\"id\": \"sub_123\"," + - "\"subscription_items\": [" + - "{\"item_price_id\": \"price_1\", \"quantity\": 1}," + - "{\"item_price_id\": \"price_2\", \"quantity\": 2}" + - "]," + - "\"addons\": [{\"id\": \"addon_1\"}]," + - "\"coupons\": []," + - "\"discounts\": [{\"id\": \"disc_1\", \"apply_till\": [1, 2, 3]}]" + - "}" + - "}"; - - String subscription = JsonUtil.getObject(json, "subscription"); - assertNotNull(subscription); - - String items = JsonUtil.getArray(subscription, "subscription_items"); - assertNotNull(items); - List itemsList = JsonUtil.parseObjectArray(items); - assertEquals(2, itemsList.size()); - - String addons = JsonUtil.getArray(subscription, "addons"); - assertNotNull(addons); - - String coupons = JsonUtil.getArray(subscription, "coupons"); - assertEquals("[]", coupons); - - String discounts = JsonUtil.getArray(subscription, "discounts"); - assertNotNull(discounts); - // Verify nested array within object within array is handled - assertTrue(discounts.contains("apply_till")); - assertTrue(discounts.contains("[1, 2, 3]") || discounts.contains("[1,2,3]")); + @Test void keysWithSpecialCharacters() { + JsonObject obj = JsonUtil.parse("{\"my-key\": \"value1\", \"my_key\": \"value2\", \"my.key\": \"value3\"}"); + assertEquals("value1", JsonUtil.getString(obj, "my-key")); + assertEquals("value2", JsonUtil.getString(obj, "my_key")); + assertEquals("value3", JsonUtil.getString(obj, "my.key")); } - } - - // ========== Edge Cases ========== - @Nested - @DisplayName("Edge Cases") - class EdgeCases { - @Test - @DisplayName("should handle whitespace variations") - void shouldHandleWhitespaceVariations() { - String json1 = "{\"key\":\"value\"}"; - String json2 = "{ \"key\" : \"value\" }"; - String json3 = "{\n \"key\"\t:\n \"value\"\n}"; - - assertEquals("value", JsonUtil.getString(json1, "key")); - assertEquals("value", JsonUtil.getString(json2, "key")); - assertEquals("value", JsonUtil.getString(json3, "key")); - } - - @Test - @DisplayName("should handle keys with special characters") - void shouldHandleKeysWithSpecialCharacters() { - String json = "{\"my-key\": \"value1\", \"my_key\": \"value2\", \"my.key\": \"value3\"}"; - assertEquals("value1", JsonUtil.getString(json, "my-key")); - assertEquals("value2", JsonUtil.getString(json, "my_key")); - assertEquals("value3", JsonUtil.getString(json, "my.key")); - } - - @Test - @DisplayName("should handle very long strings") - void shouldHandleVeryLongStrings() { + @Test void veryLongStrings() { StringBuilder longValue = new StringBuilder(); - for (int i = 0; i < 10000; i++) { - longValue.append("x"); - } - String json = "{\"long\": \"" + longValue + "\"}"; - assertEquals(longValue.toString(), JsonUtil.getString(json, "long")); + for (int i = 0; i < 10000; i++) longValue.append("x"); + JsonObject obj = JsonUtil.parse("{\"long\": \"" + longValue + "\"}"); + assertEquals(longValue.toString(), JsonUtil.getString(obj, "long")); } - @Test - @DisplayName("should handle deeply nested structures") - void shouldHandleDeeplyNestedStructures() { - // Create 10 levels of nesting + @Test void deeplyNestedStructures() { StringBuilder json = new StringBuilder(); - for (int i = 0; i < 10; i++) { - json.append("{\"level").append(i).append("\": "); - } + for (int i = 0; i < 10; i++) json.append("{\"level").append(i).append("\": "); json.append("\"deep_value\""); - for (int i = 0; i < 10; i++) { - json.append("}"); - } - - String result = json.toString(); - String level0 = JsonUtil.getObject(result, "level0"); + for (int i = 0; i < 10; i++) json.append("}"); + JsonObject root = JsonUtil.parse(json.toString()); + JsonObject level0 = JsonUtil.getJsonObject(root, "level0"); assertNotNull(level0); - assertTrue(level0.contains("deep_value")); - } - - @Test - @DisplayName("should handle array with mixed types") - void shouldHandleArrayWithMixedTypes() { - String json = "{\"mixed\": [1, \"two\", true, null, {\"key\": \"value\"}, [1, 2]]}"; - String array = JsonUtil.getArray(json, "mixed"); - assertNotNull(array); - assertTrue(array.contains("1")); - assertTrue(array.contains("\"two\"")); - assertTrue(array.contains("true")); - assertTrue(array.contains("null")); - } - - @Test - @DisplayName("should handle colons in string values") - void shouldHandleColonsInStringValues() { - String json = "{\"url\": \"https://example.com:8080/path\"}"; - assertEquals("https://example.com:8080/path", JsonUtil.getString(json, "url")); - } - - @Test - @DisplayName("should handle quotes in key names") - void shouldHandleFirstMatchForDuplicateKeys() { - // JSON spec says duplicate keys have undefined behavior, but we should handle gracefully - String json = "{\"key\": \"first\", \"key\": \"second\"}"; - String result = JsonUtil.getString(json, "key"); - // Should return one of the values (typically first) - assertNotNull(result); } - } - - // ========== Parse-Once (JsonObject-based) Tests ========== - @Nested - @DisplayName("Parse-Once JsonObject API Tests") - class ParseOnceTests { - @Test - @DisplayName("parse should return JsonObject for valid JSON") - void parseShouldReturnJsonObject() { - JsonObject obj = JsonUtil.parse("{\"id\": \"sub_123\", \"amount\": 1000}"); - assertNotNull(obj); - assertEquals("sub_123", JsonUtil.getString(obj, "id")); - assertEquals(1000L, JsonUtil.getLong(obj, "amount")); + @Test void mixedTypesInArray() { + JsonObject obj = JsonUtil.parse("{\"mixed\": [1, \"two\", true, null, {\"key\": \"value\"}, [1, 2]]}"); + JsonArray arr = JsonUtil.getJsonArray(obj, "mixed"); + assertNotNull(arr); + assertEquals(6, arr.size()); } - @Test - @DisplayName("parse should return empty JsonObject for null/empty input") - void parseShouldHandleNullAndEmpty() { - assertNotNull(JsonUtil.parse(null)); - assertTrue(JsonUtil.parse(null).entrySet().isEmpty()); - assertNotNull(JsonUtil.parse("")); - assertNotNull(JsonUtil.parse(" ")); - } - - @Test - @DisplayName("all primitive extractors should work on JsonObject") - void allPrimitiveExtractorsOnJsonObject() { - String json = "{\"s\": \"hello\", \"i\": 42, \"l\": 9876543210, \"b\": true, \"d\": 3.14, \"bd\": 123.456, \"ts\": 1605530769}"; - JsonObject obj = JsonUtil.parse(json); - - assertEquals("hello", JsonUtil.getString(obj, "s")); - assertEquals(42, JsonUtil.getInteger(obj, "i")); - assertEquals(9876543210L, JsonUtil.getLong(obj, "l")); - assertTrue(JsonUtil.getBoolean(obj, "b")); - assertEquals(3.14, JsonUtil.getDouble(obj, "d"), 0.001); - assertEquals(new BigDecimal("123.456"), JsonUtil.getBigDecimal(obj, "bd")); - Timestamp ts = JsonUtil.getTimestamp(obj, "ts"); - assertNotNull(ts); - assertEquals(1605530769000L, ts.getTime()); - } - - @Test - @DisplayName("null and missing keys should return null on JsonObject") - void nullAndMissingKeysOnJsonObject() { + @Test void nullAndMissingKeysReturnNull() { JsonObject obj = JsonUtil.parse("{\"name\": \"test\"}"); assertNull(JsonUtil.getString(obj, "missing")); assertNull(JsonUtil.getLong(obj, "missing")); @@ -1107,216 +678,14 @@ void nullAndMissingKeysOnJsonObject() { assertNull(JsonUtil.getJsonObject(obj, "missing")); assertNull(JsonUtil.getJsonArray(obj, "missing")); } - - @Test - @DisplayName("getJsonObject should extract nested objects without re-parsing") - void getJsonObjectShouldExtractNested() { - String json = "{\"customer\": {\"id\": \"cust_1\", \"email\": \"a@b.com\"}, \"amount\": 500}"; - JsonObject root = JsonUtil.parse(json); - - JsonObject customer = JsonUtil.getJsonObject(root, "customer"); - assertNotNull(customer); - assertEquals("cust_1", JsonUtil.getString(customer, "id")); - assertEquals("a@b.com", JsonUtil.getString(customer, "email")); - } - - @Test - @DisplayName("getJsonArray should extract arrays without re-parsing") - void getJsonArrayShouldExtractArrays() { - String json = "{\"items\": [{\"id\": \"item_1\"}, {\"id\": \"item_2\"}]}"; - JsonObject root = JsonUtil.parse(json); - - JsonArray items = JsonUtil.getJsonArray(root, "items"); - assertNotNull(items); - assertEquals(2, items.size()); - assertEquals("item_1", items.get(0).getAsJsonObject().get("id").getAsString()); - } - - @Test - @DisplayName("hasValue should work on JsonObject") - void hasValueOnJsonObject() { - JsonObject obj = JsonUtil.parse("{\"name\": \"test\", \"empty\": null}"); - assertTrue(JsonUtil.hasValue(obj, "name")); - assertFalse(JsonUtil.hasValue(obj, "empty")); - assertFalse(JsonUtil.hasValue(obj, "missing")); - } - - @Test - @DisplayName("mapArray should map JsonArray elements through fromJson-like function") - void mapArrayShouldWork() { - String json = "[{\"id\": \"a\"}, {\"id\": \"b\"}, {\"id\": \"c\"}]"; - JsonArray array = JsonUtil.parseToArray(json); - List ids = JsonUtil.mapArray(array, obj -> JsonUtil.getString(obj, "id")); - assertEquals(3, ids.size()); - assertEquals("a", ids.get(0)); - assertEquals("b", ids.get(1)); - assertEquals("c", ids.get(2)); - } - - @Test - @DisplayName("mapArray should return empty list for null array") - void mapArrayNullShouldReturnEmpty() { - List result = JsonUtil.mapArray(null, obj -> "x"); - assertNotNull(result); - assertTrue(result.isEmpty()); - } - - @Test - @DisplayName("mapArrayToMaps should convert array of objects to list of maps") - void mapArrayToMapsShouldWork() { - String json = "[{\"k1\": \"v1\"}, {\"k2\": 42}]"; - JsonArray array = JsonUtil.parseToArray(json); - List> maps = JsonUtil.mapArrayToMaps(array); - assertEquals(2, maps.size()); - assertEquals("v1", maps.get(0).get("k1")); - assertEquals(42L, maps.get(1).get("k2")); - } - - @Test - @DisplayName("parseArrayOfString with JsonArray should work") - void parseArrayOfStringWithJsonArray() { - JsonArray array = JsonUtil.parseToArray("[\"x\", \"y\", \"z\"]"); - List result = JsonUtil.parseArrayOfString(array); - assertEquals(3, result.size()); - assertEquals("x", result.get(0)); - } - - @Test - @DisplayName("parseArrayOfInteger with JsonArray should work") - void parseArrayOfIntegerWithJsonArray() { - JsonArray array = JsonUtil.parseToArray("[1, 2, 3]"); - List result = JsonUtil.parseArrayOfInteger(array); - assertEquals(3, result.size()); - assertEquals(1, result.get(0)); - } - - @Test - @DisplayName("parseArrayOfLong with JsonArray should work") - void parseArrayOfLongWithJsonArray() { - JsonArray array = JsonUtil.parseToArray("[1605530769000, 1605530770000]"); - List result = JsonUtil.parseArrayOfLong(array); - assertEquals(2, result.size()); - assertEquals(1605530769000L, result.get(0)); - } - - @Test - @DisplayName("parseArrayOfBoolean with JsonArray should work") - void parseArrayOfBooleanWithJsonArray() { - JsonArray array = JsonUtil.parseToArray("[true, false, true]"); - List result = JsonUtil.parseArrayOfBoolean(array); - assertEquals(3, result.size()); - assertTrue(result.get(0)); - assertFalse(result.get(1)); - } - - @Test - @DisplayName("parseArrayOfDouble with JsonArray should work") - void parseArrayOfDoubleWithJsonArray() { - JsonArray array = JsonUtil.parseToArray("[1.5, 2.7]"); - List result = JsonUtil.parseArrayOfDouble(array); - assertEquals(2, result.size()); - assertEquals(1.5, result.get(0), 0.001); - } - - @Test - @DisplayName("parseArrayOfBigDecimal with JsonArray should work") - void parseArrayOfBigDecimalWithJsonArray() { - JsonArray array = JsonUtil.parseToArray("[123.45, 678.90]"); - List result = JsonUtil.parseArrayOfBigDecimal(array); - assertEquals(2, result.size()); - } - - @Test - @DisplayName("parseJsonObjectToMap with JsonObject should work") - void parseJsonObjectToMapWithJsonObject() { - JsonObject obj = JsonUtil.parse("{\"name\": \"John\", \"age\": 30, \"active\": true}"); - Map map = JsonUtil.parseJsonObjectToMap(obj); - assertEquals("John", map.get("name")); - assertEquals(30L, map.get("age")); - assertEquals(true, map.get("active")); - } - - @Test - @DisplayName("getObject(JsonObject, key) should return JSON string") - void getObjectOnJsonObjectShouldReturnString() { - JsonObject obj = JsonUtil.parse("{\"meta\": {\"key\": \"val\"}}"); - String meta = JsonUtil.getObject(obj, "meta"); - assertNotNull(meta); - assertTrue(meta.contains("key")); - assertTrue(meta.contains("val")); - } - - @Test - @DisplayName("getArray(JsonObject, key) should return JSON string") - void getArrayOnJsonObjectShouldReturnString() { - JsonObject obj = JsonUtil.parse("{\"tags\": [\"a\", \"b\"]}"); - String tags = JsonUtil.getArray(obj, "tags"); - assertNotNull(tags); - assertTrue(tags.startsWith("[")); - assertTrue(tags.endsWith("]")); - } - } - - // ========== extractCustomFields / extractConsentFields Tests ========== - @Nested - @DisplayName("extractCustomFields / extractConsentFields Tests") - class ExtractFieldsTests { - - @Test - @DisplayName("extractCustomFields should extract cf_ prefixed fields") - void extractCustomFieldsShouldWork() { - JsonObject obj = JsonUtil.parse("{\"id\": \"sub_1\", \"cf_color\": \"blue\", \"cf_size\": \"large\", \"name\": \"test\"}"); - Set known = new HashSet<>(); - known.add("id"); - known.add("name"); - - Map cf = JsonUtil.extractCustomFields(obj, known); - assertEquals(2, cf.size()); - assertEquals("blue", cf.get("cf_color")); - assertEquals("large", cf.get("cf_size")); - } - - @Test - @DisplayName("extractCustomFields should handle null values") - void extractCustomFieldsNullValues() { - JsonObject obj = JsonUtil.parse("{\"cf_nullable\": null}"); - Map cf = JsonUtil.extractCustomFields(obj, new HashSet<>()); - assertEquals(1, cf.size()); - assertNull(cf.get("cf_nullable")); - } - - @Test - @DisplayName("extractCustomFields should exclude known fields even with cf_ prefix") - void extractCustomFieldsExcludesKnown() { - JsonObject obj = JsonUtil.parse("{\"cf_known\": \"val\"}"); - Set known = new HashSet<>(); - known.add("cf_known"); - Map cf = JsonUtil.extractCustomFields(obj, known); - assertTrue(cf.isEmpty()); - } - - @Test - @DisplayName("extractConsentFields should extract cs_ prefixed fields") - void extractConsentFieldsShouldWork() { - JsonObject obj = JsonUtil.parse("{\"id\": \"cust_1\", \"cs_marketing\": true, \"cs_analytics\": false}"); - Set known = new HashSet<>(); - known.add("id"); - - Map cs = JsonUtil.extractConsentFields(obj, known); - assertEquals(2, cs.size()); - assertEquals(true, cs.get("cs_marketing")); - assertEquals(false, cs.get("cs_analytics")); - } } - // ========== Parse-Once Real-World Scenario ========== + // ========== Real-World Scenarios ========== @Nested - @DisplayName("Parse-Once Real-World Scenario") - class ParseOnceRealWorld { + @DisplayName("Real-World Scenarios") + class RealWorldScenarios { - @Test - @DisplayName("should parse complex response with single parse call") - void shouldParseComplexResponseWithSingleParse() { + @Test void complexSubscriptionResponse() { String json = "{" + "\"subscription\": {" + "\"id\": \"sub_123\"," + @@ -1342,32 +711,55 @@ void shouldParseComplexResponseWithSingleParse() { assertEquals("sub_123", JsonUtil.getString(sub, "id")); assertEquals("active", JsonUtil.getString(sub, "status")); - assertEquals("cust_456", JsonUtil.getString(sub, "customer_id")); assertEquals(5000L, JsonUtil.getLong(sub, "mrr")); assertEquals(1605530769000L, JsonUtil.getTimestamp(sub, "created_at").getTime()); assertFalse(JsonUtil.getBoolean(sub, "deleted")); assertEquals(1.25, JsonUtil.getDouble(sub, "exchange_rate"), 0.001); JsonArray items = JsonUtil.getJsonArray(sub, "subscription_items"); - assertNotNull(items); assertEquals(2, items.size()); List itemIds = JsonUtil.mapArray(items, obj -> JsonUtil.getString(obj, "item_price_id")); assertEquals("price_1", itemIds.get(0)); assertEquals("price_2", itemIds.get(1)); JsonObject shipping = JsonUtil.getJsonObject(sub, "shipping_address"); - assertNotNull(shipping); assertEquals("NYC", JsonUtil.getString(shipping, "city")); JsonArray coupons = JsonUtil.getJsonArray(sub, "coupons"); - assertNotNull(coupons); assertEquals(0, coupons.size()); - JsonObject metaObj = JsonUtil.getJsonObject(sub, "meta_data"); - assertNotNull(metaObj); - Map meta = JsonUtil.parseJsonObjectToMap(metaObj); + Map meta = JsonUtil.parseJsonObjectToMap(JsonUtil.getJsonObject(sub, "meta_data")); assertEquals("api", meta.get("source")); } + + @Test void transactionListResponse() { + String json = "{" + + "\"list\": [{\"transaction\": {" + + "\"id\": \"txn_AzZhUGSPAkLskJQo\"," + + "\"amount\": 10000," + + "\"linked_invoices\": [{\"invoice_id\": \"DemoInv_103\", \"applied_amount\": 10000}]," + + "\"linked_refunds\": []" + + "}}]," + + "\"next_offset\": null" + + "}"; + + JsonObject root = JsonUtil.parse(json); + JsonArray list = JsonUtil.getJsonArray(root, "list"); + assertNotNull(list); + assertEquals(1, list.size()); + + JsonObject wrapper = list.get(0).getAsJsonObject(); + JsonObject txn = JsonUtil.getJsonObject(wrapper, "transaction"); + assertEquals("txn_AzZhUGSPAkLskJQo", JsonUtil.getString(txn, "id")); + assertEquals(10000, JsonUtil.getInteger(txn, "amount")); + + JsonArray invoices = JsonUtil.getJsonArray(txn, "linked_invoices"); + assertEquals(1, invoices.size()); + + JsonArray refunds = JsonUtil.getJsonArray(txn, "linked_refunds"); + assertEquals(0, refunds.size()); + + assertNull(JsonUtil.getString(root, "next_offset")); + } } } - From 3e77811e29f627258ff941c08901ba7b39732527 Mon Sep 17 00:00:00 2001 From: cb-karthikp Date: Tue, 24 Feb 2026 14:08:46 +0530 Subject: [PATCH 4/6] handle exception with jsonutil --- .../com/chargebee/v4/exceptions/APIException.java | 3 ++- .../java/com/chargebee/v4/internal/JsonUtil.java | 12 ++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/chargebee/v4/exceptions/APIException.java b/src/main/java/com/chargebee/v4/exceptions/APIException.java index e2a924ae..67929261 100644 --- a/src/main/java/com/chargebee/v4/exceptions/APIException.java +++ b/src/main/java/com/chargebee/v4/exceptions/APIException.java @@ -248,7 +248,8 @@ private List extractParams(String jsonResponse) { /** Extract error_cause_id from error response. */ private String extractErrorCauseId(String jsonResponse) { if (jsonResponse != null) { - return JsonUtil.getString(JsonUtil.parse(jsonResponse), "error_cause_id"); + JsonObject obj = JsonUtil.parse(jsonResponse); + return JsonUtil.getString(obj, "error_cause_id"); } return null; } diff --git a/src/main/java/com/chargebee/v4/internal/JsonUtil.java b/src/main/java/com/chargebee/v4/internal/JsonUtil.java index c2ba6411..28d0653d 100644 --- a/src/main/java/com/chargebee/v4/internal/JsonUtil.java +++ b/src/main/java/com/chargebee/v4/internal/JsonUtil.java @@ -199,6 +199,18 @@ public static List> mapArrayToMaps(JsonArray array) { return result; } + /** Serializes each JsonObject element to its JSON string representation. */ + public static List parseObjectArray(JsonArray array) { + List result = new ArrayList<>(); + if (array == null) return result; + for (JsonElement elem : array) { + if (elem != null && elem.isJsonObject()) { + result.add(elem.toString()); + } + } + return result; + } + /** Parses a JsonArray of strings into a List. */ public static List parseArrayOfString(JsonArray array) { List result = new ArrayList<>(); From f3f79ad0ec88332c73ec00fc093dc7ce61c95d47 Mon Sep 17 00:00:00 2001 From: cb-karthikp Date: Tue, 24 Feb 2026 14:33:59 +0530 Subject: [PATCH 5/6] add null check --- .../chargebee/v4/models/coupon/Coupon.java | 23 +++++++++++++------ .../v4/models/customer/Customer.java | 7 ++++-- .../differentialPrice/DifferentialPrice.java | 6 ++++- .../v4/models/impactedItem/ImpactedItem.java | 6 ++++- .../impactedItemPrice/ImpactedItemPrice.java | 6 ++++- .../ImpactedSubscription.java | 7 ++++-- ...ationItemListApplicableAddonsResponse.java | 7 ++++-- .../Pc2MigrationItemListResponse.java | 7 ++++-- .../Pc2MigrationItemFamilyListResponse.java | 7 ++++-- .../Pc2MigrationItemPriceListResponse.java | 7 ++++-- .../chargebee/v4/models/product/Product.java | 6 ++++- .../com/chargebee/v4/models/quote/Quote.java | 6 ++++- .../UsageEventBatchIngestResponse.java | 6 +++-- 13 files changed, 75 insertions(+), 26 deletions(-) diff --git a/src/main/java/com/chargebee/v4/models/coupon/Coupon.java b/src/main/java/com/chargebee/v4/models/coupon/Coupon.java index 099174f5..bdd07dff 100644 --- a/src/main/java/com/chargebee/v4/models/coupon/Coupon.java +++ b/src/main/java/com/chargebee/v4/models/coupon/Coupon.java @@ -884,8 +884,10 @@ public static ItemConstraints fromJson(JsonObject jsonObj) { obj.constraint = Constraint.fromString(JsonUtil.getString(jsonObj, "constraint")); - obj.itemPriceIds = - JsonUtil.mapArrayToObjects(JsonUtil.getJsonArray(jsonObj, "item_price_ids")); + JsonArray __itemPriceIdsArr = JsonUtil.getJsonArray(jsonObj, "item_price_ids"); + if (__itemPriceIdsArr != null) { + obj.itemPriceIds = JsonUtil.mapArrayToObjects(__itemPriceIdsArr); + } return obj; } @@ -982,13 +984,20 @@ public static ItemConstraintCriteria fromJson(JsonObject jsonObj) { obj.itemType = ItemType.fromString(JsonUtil.getString(jsonObj, "item_type")); - obj.currencies = JsonUtil.mapArrayToObjects(JsonUtil.getJsonArray(jsonObj, "currencies")); + JsonArray __currenciesArr = JsonUtil.getJsonArray(jsonObj, "currencies"); + if (__currenciesArr != null) { + obj.currencies = JsonUtil.mapArrayToObjects(__currenciesArr); + } - obj.itemFamilyIds = - JsonUtil.mapArrayToObjects(JsonUtil.getJsonArray(jsonObj, "item_family_ids")); + JsonArray __itemFamilyIdsArr = JsonUtil.getJsonArray(jsonObj, "item_family_ids"); + if (__itemFamilyIdsArr != null) { + obj.itemFamilyIds = JsonUtil.mapArrayToObjects(__itemFamilyIdsArr); + } - obj.itemPricePeriods = - JsonUtil.mapArrayToObjects(JsonUtil.getJsonArray(jsonObj, "item_price_periods")); + JsonArray __itemPricePeriodsArr = JsonUtil.getJsonArray(jsonObj, "item_price_periods"); + if (__itemPricePeriodsArr != null) { + obj.itemPricePeriods = JsonUtil.mapArrayToObjects(__itemPricePeriodsArr); + } return obj; } diff --git a/src/main/java/com/chargebee/v4/models/customer/Customer.java b/src/main/java/com/chargebee/v4/models/customer/Customer.java index 39b84545..baed6762 100644 --- a/src/main/java/com/chargebee/v4/models/customer/Customer.java +++ b/src/main/java/com/chargebee/v4/models/customer/Customer.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.customer; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonArray; import com.google.gson.JsonObject; import java.sql.Timestamp; import java.util.List; @@ -1065,8 +1066,10 @@ public static Customer fromJson(JsonObject jsonObj) { obj.createdFromIp = JsonUtil.getString(jsonObj, "created_from_ip"); - obj.exemptionDetails = - JsonUtil.mapArrayToObjects(JsonUtil.getJsonArray(jsonObj, "exemption_details")); + JsonArray __exemptionDetailsArr = JsonUtil.getJsonArray(jsonObj, "exemption_details"); + if (__exemptionDetailsArr != null) { + obj.exemptionDetails = JsonUtil.mapArrayToObjects(__exemptionDetailsArr); + } obj.taxability = Taxability.fromString(JsonUtil.getString(jsonObj, "taxability")); diff --git a/src/main/java/com/chargebee/v4/models/differentialPrice/DifferentialPrice.java b/src/main/java/com/chargebee/v4/models/differentialPrice/DifferentialPrice.java index e56adcad..7448e495 100644 --- a/src/main/java/com/chargebee/v4/models/differentialPrice/DifferentialPrice.java +++ b/src/main/java/com/chargebee/v4/models/differentialPrice/DifferentialPrice.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.differentialPrice; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonArray; import com.google.gson.JsonObject; import java.sql.Timestamp; import java.util.List; @@ -446,7 +447,10 @@ public static ParentPeriods fromJson(JsonObject jsonObj) { obj.periodUnit = PeriodUnit.fromString(JsonUtil.getString(jsonObj, "period_unit")); - obj.period = JsonUtil.mapArrayToObjects(JsonUtil.getJsonArray(jsonObj, "period")); + JsonArray __periodArr = JsonUtil.getJsonArray(jsonObj, "period"); + if (__periodArr != null) { + obj.period = JsonUtil.mapArrayToObjects(__periodArr); + } return obj; } diff --git a/src/main/java/com/chargebee/v4/models/impactedItem/ImpactedItem.java b/src/main/java/com/chargebee/v4/models/impactedItem/ImpactedItem.java index 4eeb4dbf..4445a3be 100644 --- a/src/main/java/com/chargebee/v4/models/impactedItem/ImpactedItem.java +++ b/src/main/java/com/chargebee/v4/models/impactedItem/ImpactedItem.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.impactedItem; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonArray; import com.google.gson.JsonObject; import java.sql.Timestamp; import java.util.List; @@ -39,7 +40,10 @@ public static ImpactedItem fromJson(JsonObject jsonObj) { obj.count = JsonUtil.getInteger(jsonObj, "count"); - obj.items = JsonUtil.mapArrayToObjects(JsonUtil.getJsonArray(jsonObj, "items")); + JsonArray __itemsArr = JsonUtil.getJsonArray(jsonObj, "items"); + if (__itemsArr != null) { + obj.items = JsonUtil.mapArrayToObjects(__itemsArr); + } JsonObject __downloadObj = JsonUtil.getJsonObject(jsonObj, "download"); if (__downloadObj != null) { diff --git a/src/main/java/com/chargebee/v4/models/impactedItemPrice/ImpactedItemPrice.java b/src/main/java/com/chargebee/v4/models/impactedItemPrice/ImpactedItemPrice.java index 594c63c8..af637a31 100644 --- a/src/main/java/com/chargebee/v4/models/impactedItemPrice/ImpactedItemPrice.java +++ b/src/main/java/com/chargebee/v4/models/impactedItemPrice/ImpactedItemPrice.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.impactedItemPrice; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonArray; import com.google.gson.JsonObject; import java.sql.Timestamp; import java.util.List; @@ -39,7 +40,10 @@ public static ImpactedItemPrice fromJson(JsonObject jsonObj) { obj.count = JsonUtil.getInteger(jsonObj, "count"); - obj.itemPrices = JsonUtil.mapArrayToObjects(JsonUtil.getJsonArray(jsonObj, "item_prices")); + JsonArray __itemPricesArr = JsonUtil.getJsonArray(jsonObj, "item_prices"); + if (__itemPricesArr != null) { + obj.itemPrices = JsonUtil.mapArrayToObjects(__itemPricesArr); + } JsonObject __downloadObj = JsonUtil.getJsonObject(jsonObj, "download"); if (__downloadObj != null) { diff --git a/src/main/java/com/chargebee/v4/models/impactedSubscription/ImpactedSubscription.java b/src/main/java/com/chargebee/v4/models/impactedSubscription/ImpactedSubscription.java index e7feea21..f334f7e5 100644 --- a/src/main/java/com/chargebee/v4/models/impactedSubscription/ImpactedSubscription.java +++ b/src/main/java/com/chargebee/v4/models/impactedSubscription/ImpactedSubscription.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.impactedSubscription; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonArray; import com.google.gson.JsonObject; import java.sql.Timestamp; import java.util.List; @@ -39,8 +40,10 @@ public static ImpactedSubscription fromJson(JsonObject jsonObj) { obj.count = JsonUtil.getInteger(jsonObj, "count"); - obj.subscriptionIds = - JsonUtil.mapArrayToObjects(JsonUtil.getJsonArray(jsonObj, "subscription_ids")); + JsonArray __subscriptionIdsArr = JsonUtil.getJsonArray(jsonObj, "subscription_ids"); + if (__subscriptionIdsArr != null) { + obj.subscriptionIds = JsonUtil.mapArrayToObjects(__subscriptionIdsArr); + } JsonObject __downloadObj = JsonUtil.getJsonObject(jsonObj, "download"); if (__downloadObj != null) { diff --git a/src/main/java/com/chargebee/v4/models/pc2MigrationItem/responses/Pc2MigrationItemListApplicableAddonsResponse.java b/src/main/java/com/chargebee/v4/models/pc2MigrationItem/responses/Pc2MigrationItemListApplicableAddonsResponse.java index 940faa8b..44965dfe 100644 --- a/src/main/java/com/chargebee/v4/models/pc2MigrationItem/responses/Pc2MigrationItemListApplicableAddonsResponse.java +++ b/src/main/java/com/chargebee/v4/models/pc2MigrationItem/responses/Pc2MigrationItemListApplicableAddonsResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.exceptions.ChargebeeException; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonArray; import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; import com.chargebee.v4.services.Pc2MigrationItemService; @@ -47,8 +48,9 @@ public static Pc2MigrationItemListApplicableAddonsResponse fromJson(String json) try { JsonObject jsonObj = JsonUtil.parse(json); + JsonArray __listArr = JsonUtil.getJsonArray(jsonObj, "list"); List> list = - JsonUtil.mapArrayToMaps(JsonUtil.getJsonArray(jsonObj, "list")); + __listArr != null ? JsonUtil.mapArrayToMaps(__listArr) : null; String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); @@ -71,8 +73,9 @@ public static Pc2MigrationItemListApplicableAddonsResponse fromJson( try { JsonObject jsonObj = JsonUtil.parse(json); + JsonArray __listArr = JsonUtil.getJsonArray(jsonObj, "list"); List> list = - JsonUtil.mapArrayToMaps(JsonUtil.getJsonArray(jsonObj, "list")); + __listArr != null ? JsonUtil.mapArrayToMaps(__listArr) : null; String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); diff --git a/src/main/java/com/chargebee/v4/models/pc2MigrationItem/responses/Pc2MigrationItemListResponse.java b/src/main/java/com/chargebee/v4/models/pc2MigrationItem/responses/Pc2MigrationItemListResponse.java index c720c21a..39c758a7 100644 --- a/src/main/java/com/chargebee/v4/models/pc2MigrationItem/responses/Pc2MigrationItemListResponse.java +++ b/src/main/java/com/chargebee/v4/models/pc2MigrationItem/responses/Pc2MigrationItemListResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.exceptions.ChargebeeException; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonArray; import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; import com.chargebee.v4.services.Pc2MigrationItemService; @@ -44,8 +45,9 @@ public static Pc2MigrationItemListResponse fromJson(String json) { try { JsonObject jsonObj = JsonUtil.parse(json); + JsonArray __listArr = JsonUtil.getJsonArray(jsonObj, "list"); List> list = - JsonUtil.mapArrayToMaps(JsonUtil.getJsonArray(jsonObj, "list")); + __listArr != null ? JsonUtil.mapArrayToMaps(__listArr) : null; String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); @@ -67,8 +69,9 @@ public static Pc2MigrationItemListResponse fromJson( try { JsonObject jsonObj = JsonUtil.parse(json); + JsonArray __listArr = JsonUtil.getJsonArray(jsonObj, "list"); List> list = - JsonUtil.mapArrayToMaps(JsonUtil.getJsonArray(jsonObj, "list")); + __listArr != null ? JsonUtil.mapArrayToMaps(__listArr) : null; String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); diff --git a/src/main/java/com/chargebee/v4/models/pc2MigrationItemFamily/responses/Pc2MigrationItemFamilyListResponse.java b/src/main/java/com/chargebee/v4/models/pc2MigrationItemFamily/responses/Pc2MigrationItemFamilyListResponse.java index 7e111264..1f098d9f 100644 --- a/src/main/java/com/chargebee/v4/models/pc2MigrationItemFamily/responses/Pc2MigrationItemFamilyListResponse.java +++ b/src/main/java/com/chargebee/v4/models/pc2MigrationItemFamily/responses/Pc2MigrationItemFamilyListResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.exceptions.ChargebeeException; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonArray; import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; import com.chargebee.v4.services.Pc2MigrationItemFamilyService; @@ -46,8 +47,9 @@ public static Pc2MigrationItemFamilyListResponse fromJson(String json) { try { JsonObject jsonObj = JsonUtil.parse(json); + JsonArray __listArr = JsonUtil.getJsonArray(jsonObj, "list"); List> list = - JsonUtil.mapArrayToMaps(JsonUtil.getJsonArray(jsonObj, "list")); + __listArr != null ? JsonUtil.mapArrayToMaps(__listArr) : null; String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); @@ -69,8 +71,9 @@ public static Pc2MigrationItemFamilyListResponse fromJson( try { JsonObject jsonObj = JsonUtil.parse(json); + JsonArray __listArr = JsonUtil.getJsonArray(jsonObj, "list"); List> list = - JsonUtil.mapArrayToMaps(JsonUtil.getJsonArray(jsonObj, "list")); + __listArr != null ? JsonUtil.mapArrayToMaps(__listArr) : null; String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); diff --git a/src/main/java/com/chargebee/v4/models/pc2MigrationItemPrice/responses/Pc2MigrationItemPriceListResponse.java b/src/main/java/com/chargebee/v4/models/pc2MigrationItemPrice/responses/Pc2MigrationItemPriceListResponse.java index 99a9cd10..e57fb954 100644 --- a/src/main/java/com/chargebee/v4/models/pc2MigrationItemPrice/responses/Pc2MigrationItemPriceListResponse.java +++ b/src/main/java/com/chargebee/v4/models/pc2MigrationItemPrice/responses/Pc2MigrationItemPriceListResponse.java @@ -4,6 +4,7 @@ import com.chargebee.v4.exceptions.ChargebeeException; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonArray; import com.google.gson.JsonObject; import com.chargebee.v4.transport.Response; import com.chargebee.v4.services.Pc2MigrationItemPriceService; @@ -46,8 +47,9 @@ public static Pc2MigrationItemPriceListResponse fromJson(String json) { try { JsonObject jsonObj = JsonUtil.parse(json); + JsonArray __listArr = JsonUtil.getJsonArray(jsonObj, "list"); List> list = - JsonUtil.mapArrayToMaps(JsonUtil.getJsonArray(jsonObj, "list")); + __listArr != null ? JsonUtil.mapArrayToMaps(__listArr) : null; String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); @@ -69,8 +71,9 @@ public static Pc2MigrationItemPriceListResponse fromJson( try { JsonObject jsonObj = JsonUtil.parse(json); + JsonArray __listArr = JsonUtil.getJsonArray(jsonObj, "list"); List> list = - JsonUtil.mapArrayToMaps(JsonUtil.getJsonArray(jsonObj, "list")); + __listArr != null ? JsonUtil.mapArrayToMaps(__listArr) : null; String nextOffset = JsonUtil.getString(jsonObj, "next_offset"); diff --git a/src/main/java/com/chargebee/v4/models/product/Product.java b/src/main/java/com/chargebee/v4/models/product/Product.java index c8be5bae..98dd21f9 100644 --- a/src/main/java/com/chargebee/v4/models/product/Product.java +++ b/src/main/java/com/chargebee/v4/models/product/Product.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.product; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonArray; import com.google.gson.JsonObject; import java.sql.Timestamp; import java.util.List; @@ -296,7 +297,10 @@ public static Options fromJson(JsonObject jsonObj) { obj.name = JsonUtil.getString(jsonObj, "name"); - obj.values = JsonUtil.mapArrayToObjects(JsonUtil.getJsonArray(jsonObj, "values")); + JsonArray __valuesArr = JsonUtil.getJsonArray(jsonObj, "values"); + if (__valuesArr != null) { + obj.values = JsonUtil.mapArrayToObjects(__valuesArr); + } obj.defaultValue = JsonUtil.getString(jsonObj, "default_value"); diff --git a/src/main/java/com/chargebee/v4/models/quote/Quote.java b/src/main/java/com/chargebee/v4/models/quote/Quote.java index 3007983d..a9ccb371 100644 --- a/src/main/java/com/chargebee/v4/models/quote/Quote.java +++ b/src/main/java/com/chargebee/v4/models/quote/Quote.java @@ -8,6 +8,7 @@ package com.chargebee.v4.models.quote; import com.chargebee.v4.internal.JsonUtil; +import com.google.gson.JsonArray; import com.google.gson.JsonObject; import java.math.BigDecimal; import java.sql.Timestamp; @@ -488,7 +489,10 @@ public static Quote fromJson(JsonObject jsonObj) { obj.currencyCode = JsonUtil.getString(jsonObj, "currency_code"); - obj.notes = JsonUtil.mapArrayToObjects(JsonUtil.getJsonArray(jsonObj, "notes")); + JsonArray __notesArr = JsonUtil.getJsonArray(jsonObj, "notes"); + if (__notesArr != null) { + obj.notes = JsonUtil.mapArrayToObjects(__notesArr); + } obj.contractTermStart = JsonUtil.getTimestamp(jsonObj, "contract_term_start"); diff --git a/src/main/java/com/chargebee/v4/models/usageEvent/responses/UsageEventBatchIngestResponse.java b/src/main/java/com/chargebee/v4/models/usageEvent/responses/UsageEventBatchIngestResponse.java index 4bd8d701..098d8746 100644 --- a/src/main/java/com/chargebee/v4/models/usageEvent/responses/UsageEventBatchIngestResponse.java +++ b/src/main/java/com/chargebee/v4/models/usageEvent/responses/UsageEventBatchIngestResponse.java @@ -37,8 +37,10 @@ public static UsageEventBatchIngestResponse fromJson(String json, Response httpR builder.batchId(JsonUtil.getString(jsonObj, "batch_id")); - builder.failedEvents( - JsonUtil.mapArrayToObjects(JsonUtil.getJsonArray(jsonObj, "failed_events"))); + com.google.gson.JsonArray __failedEventsArr = JsonUtil.getJsonArray(jsonObj, "failed_events"); + if (__failedEventsArr != null) { + builder.failedEvents(JsonUtil.mapArrayToObjects(__failedEventsArr)); + } builder.httpResponse(httpResponse); return builder.build(); From 631ece3f9912c377504942ae243b151c79beb902 Mon Sep 17 00:00:00 2001 From: cb-karthikp Date: Tue, 24 Feb 2026 17:07:16 +0530 Subject: [PATCH 6/6] version bump-up --- CHANGELOG.md | 10 ++++++++++ VERSION | 2 +- build.gradle.kts | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dbce63f5..9ebccaa7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,13 @@ +### v4.4.0 (2026-02-24) +* * * + +### Improvements: +* Replaced the internal regex-based JSON parser with [Google Gson](https://github.com/google/gson) for reliable, spec-compliant JSON handling. +* Added comprehensive test coverage for the internal `JsonUtil` utility. + +### Dependencies: +* Added `com.google.code.gson:gson:2.13.2` as a compile dependency (transitive for SDK consumers). Minimum compatible Gson version is `2.8.6`. See [README](README.md#dependencies) for version conflict guidance. + ### v4.3.0 (2026-02-20) * * * diff --git a/VERSION b/VERSION index 80895903..fdc66988 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -4.3.0 +4.4.0 diff --git a/build.gradle.kts b/build.gradle.kts index 822fe15d..8c34a74c 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -7,7 +7,7 @@ plugins { } group = "com.chargebee" -version = "4.3.0" +version = "4.4.0" description = "Java client library for ChargeBee" // Project metadata